Resizing Range In VBA
Oct 26, 2013
I am trying to copy down a range of formulae using the resize function. Here's the code I have :-
Code:
Dim no_of_transactions As Long
no_of_transactions = Last_Row_of_data(main_workbook.Sheets("working").Range("g2"))
main_workbook.Sheets("working").Range("w2:ak2").resize(no_of_transactions,1)
However I am told by the vba editor that I need an = sign ? The function Last_Row_of_data tells me the number of rows that I have.
View 4 Replies
ADVERTISEMENT
Sep 30, 2012
I have table1 that has its original range as A1:B3. Depending on the amount of n in another column, I want table1 to be resized to A1:Bn.
I have tried with
ActiveSheet.ListObjects("Table1").Resize range("A1", "witdh")
with "width" being a variant.
View 9 Replies
View Related
Apr 18, 2006
I have a worksheet named Advisers with a range also named Advisers, the range is a list of names which is added or deleted from by use of a UserForm.
I have the following lines of -
The first populates the worksheet
and
The second is supposed to resize the range Advisers accordingly but it gives a Run-time error I've tried the 2 examples below
c.Offset(0, 0).Value = Me.Adviser_txt.Value
Worksheets("Advisers").Resize(Range("Advisers").Rows.Count, 1).Name = "Advisers"
c.Offset(0, 0).Value = Me.Adviser_txt.Value
Worksheets(Sheet2).Resize(Range("Advisers").Rows.Count, 1).Name = "Advisers"
View 9 Replies
View Related
Aug 2, 2007
= SUMIFS(E9:E1494,C9:C1494,1) This formula works ok. If I rename range E9:E1494 as "Col_1" and change the formula to =SUMIFS(Col_1,C9:C1494,1). I get #VALUE error.
The range is formatted as number.
Also ...
If I delete some cells in a range, referring formulae are modified accordingly, but if I add cells in the range the formulae do not recognize the change
View 4 Replies
View Related
Apr 8, 2008
Is it possible to re-size a non-contiguous range? I'm guessing "no", and a Google trawl hasn't provided me with anything.
Here's what I'm trying to do:
dim mult_rng as range
dim rng2 as range
set mult_rng = range("A1:B1,D1:E1")
set rng2 = mult_rng.resize(rowsize:=10)
That is, my original range is comprised of non-contiguous cells in the same row. When re-sizing, I'm trying to increase the number of rows, but leave the columns the same.
Like I said, my gut instinct says that this isn't possible using the 'resize' property. Can anyone think of another method to use? My constraints are that the original mult_rng isn't always the same (and isn't always non-contiguous).
View 9 Replies
View Related
Jan 19, 2007
I can't find a way to re-size the name box (the one in the top left hand corner of a spreadsheet, to the left of the formula bar), or change the type size that this box uses.
I've looked through Excel help, but I can only find help on re-sizing toolbars and not the name box.
View 9 Replies
View Related
Oct 13, 2011
I now have 5 textboxes "on top" of one other (i.e. vertically arranged). I would like to - depending on which checkbox is checked - extend the top one all the way down and make the bottom four invisible. I'm pretty sure I can handle the second part:
Code:
Textbox2.visible=False
For example. How to resize a textbox?
View 7 Replies
View Related
Jun 3, 2006
i have a command button on a userform that resizes/inlarges a userform.
i need some code to place the new sized form in the centre of the screen once the resizing code is executed.
View 3 Replies
View Related
Jun 7, 2013
I have created this Excel schedule that is attached. The point of the schedule is to organize Jobs and Crew members. I have VBA code in, so when I calculate how long the job should take, the arrows next to the job will automatically extend. (This should all make sense if you take a look at the attachment.) The only problem is that my arrows do not extend the correct distance. In the attached file I have scheduled "James Lorenz" to do a job starting on tuesday, towards the bottom of the page I did my calculation that figures he should be on that job for 9.5 days. I would like the Arrow next to James' job to extend 9.5 days on the calender instead of 9.5 centimeters or whatever it is doing now.
View 9 Replies
View Related
Feb 13, 2014
Lets say i type for now...
A1 = USA
B1 = Philippines
and then later
A1 = dog
B1 = cat
Is there a way that the width would automatically adjust even as I change the values of the given cells; meaning, if a word is long, the width will automatically adjust "longer", if a word is short, then it will automatically adjust "shorter".
I know how the "AutoFit Column Width" works but I don't want to press that every time my values change (words becoming shorter or longer).
View 4 Replies
View Related
May 17, 2014
I finally have the merged cells resizing the way I need, however it seems to lock the cell after the process not allowing it to be edited again until I unlock the sheet. below is the current code I am using
[Code] .....
View 5 Replies
View Related
Jun 3, 2006
I have a two-parter...
1) Is it possible to write a macro that will resize fonts in a chart (axes, text boxes) to specific sizes?
2) I usually copy chart sheets and paste them into Publisher but I have to resize them because they are huge when pasted. I would like to create a toolbar command that will take the selected chart sheet (not just a chart in a worksheet) and resize it and its components (part 1) to specific dimensions, then copy it as a picture so that I can simply go to Publisher and paste the chart after pressing said button in Excel.
View 9 Replies
View Related
May 4, 2007
I have made charts in VBA charts that needs to be placed on specific position and have specific sizes on a chartsheet. I use plotarea (top, left, width, height) for that. Unfortunately when I set these values they keep chaning, there is some scaling going on in Excel and they won't get the specified size. I have been looking on the internet and finally I found a piece of code which works, but still not good enough, because the legend is also not good positioned
De data for resizing the new charts (ChtNew), the legends and the charttitle I get from other charts (ChtOrig). The legend.legendposition of ChtOrig does not have a value but it still have a top,left,height en width which I use.
I show you my code, the part with the for-next is taken from the internet.
I am trying to find a solution now for 3 days and now I only dream of huge charts (which is not good). So please can someone help me with this? This is the last forum, that I can try, I didn't get reactions from others.
with ChtNew.legend
.Top = ChtOrig.Legend.Top
.Height = ChtOrig.Legend.Height
.Left = ChtOrig.Legend.Left
.Width = ChtOrig.Legend.Width '* 1.1
.Top = ChtOrig.Legend.Top + ChtOrig.ChartTitle.Top
end with
With ChtNew.Plotarea
.Top = ChtOrig.PlotArea.Top
.Height = ChtOrig.PlotArea.Height
.Width = ChtOrig.PlotArea.Width
.Left = ChtOrig.PlotArea.Left
For i = 1 To ChtOrig.PlotArea.Top........
View 9 Replies
View Related
Jun 7, 2006
create a form that will look at the spreadsheet and figure out which of the 32 possible checkboxes will be used and resize accordingly. I can make it so that only the checkboxes I want are visible using the .visible property, but for the sake of aesthetics I'm wondering if there is a way to disable the checkboxes I don't want and to resize the form to fit the checkboxes I do want. I just don't want a form that looks like it has checkboxes put on it at random spots.
View 3 Replies
View Related
Jan 31, 2013
Ive been trying to find a way of inserting a picture into a defined merged cell. Once I insert the pic I would like it to auto size/fit into the merged cells.
I have only managed to do this by either resizing the pic's first, or running a retro macro to resize the image. Just wondering if there was an easier way?
View 4 Replies
View Related
Sep 10, 2013
how to stop rows resizing with text which paste into cells
View 1 Replies
View Related
Mar 26, 2014
My workbook operates in full screen mode simly to make it looks a bit nicer. I have some + - buttons that call a macro to change the scale of the axes of a chart (sort of a zoom effect). For some reason, whenever I run these macros my workbook exits out of full screen mode.
Here's an example of the zoom code:
ActiveSheet.ChartObjects("Chart 115").Activate
ActiveChart.Axes(xlValue).Select
ActiveChart.Axes(xlValue).MinimumScale = 200000
ActiveSheet.Range("a1").Select
View 2 Replies
View Related
Aug 14, 2014
I imported a picture and changed the properties thus:
Lock aspect ratio is set.
Move and size with cells is set.
If I resize the picture itself, the aspect ratio is maintained - good. However, if I make the column narrower, the pictures width changes, the height remains the same and it acquires a new locked aspect ratio - bad.
View 4 Replies
View Related
Jan 24, 2014
I'm trying to make this macro work to resize images for our fashion Look Book. In theory, it should work. But of course it does not Here is the code we are using:
Code:
Sub BIGcrop()
Selection.Height = 507.6
x = Selection.ShapeRange.Width
y = x / 2
Z = y - 144
[Code]....
I want all my pictures to have a height of 7.05 inches and a width of 4. The height comes out different everytime depending on the scaling of the template I'm using. I need it to adjust accordingly. I'm open to having the image move into merged cells, as long as it will first adjust the height and then crop the sides (so the orientation stays the same).
View 4 Replies
View Related
Jul 7, 2013
I am trying to take two random Mouse click selections and swap a set of ranges associated with the cells that are selected. For example if the user clicks on A1 it will resize(3,22) and store the selection as a variable to be swapped with another selection. Here is what I have so far but I keep getting a object required error on rngEmp1.
VB:
Sub SwapGroup()
If Selection.Cells.Count < 8 Then
MsgBox "Please Select two Groups to swap. Press and hold 'Ctrl' in between your selections", , "Swap Groups"
[Code] .....
View 4 Replies
View Related
Jun 9, 2008
I have several charts which I want to make the same size, without some getting "compressed" and others "stretched"?
My goal is in other words to get uniform diagrams.
View 10 Replies
View Related
Mar 16, 2013
Trying to assign code to comm. button on User form to copy lets say:
(sheet1, rangeB2:B21) to (sheet2, first blank row rangeB2:B21) and paste it as text value one more question: what to be aware in case of sheets format (merged cells, hidden rows...)
View 4 Replies
View Related
Oct 7, 2009
Need a code using application.inputbox to get a range, then use that range to copy and paste the range's link and format to a different sheet? The specifics don't matter, I just can't figure out the syntax. Here is what I have currently:
View 2 Replies
View Related
Jan 6, 2010
I'm trying to select a range that will be changing by column. I'm not sure why my syntax isn't working. What I've got:
View 2 Replies
View Related
Aug 6, 2013
I need method, using a button, that looks at a cell--say EO2, for example--, looks back on a master worksheet at a specified row and range for a match, then looks at the information from a specified range below the matching cell (The information in this column will either be blank or have an "X" in the cell), and then those rows that do not have an "X" will be hidden in the corresponding rows in the working worksheet. Therefore, if at any time the value in "EO2" ever changes, then it will automatically find a new match and repopulate and hide information as before. About 130 columns will have its own button so that a "query" can be made that depends on the information in a particular cell in that column.
The master worksheet now has matrix of 287 rows and 58 columns. Each row is for an operating procedure and each column shows a job code. An "X" in a coordinate cell for a column/row shows whether that job code is responsible for knowing that operating procedure. So, on the working sheet, an employee's primary job code is given underneath his or her name. When the button is pushed, all the operating procedures not required for a given person will be hidden and only the required ones will remain visible--grouped, if you will. Qualification dates will be easier to see now that the information is consolidated. Whenever someone transfers to a new position, a new code will be inputed on the working sheet. When the button is pushed, a new grouping will result. Any operating instructions that overlap will still have qualification dates, so that information will not need to be transcribed.
View 9 Replies
View Related
Feb 7, 2014
I am working in excel 2010. I have a tracking document that lists free tickets and their expiry dates. In the adjacent columns we track redemption details of these free tickets. What I want to do is return the oldest expiration date from A only if the ticket has not been used (i.e. B is empty). This will allow me to see the date the upcoming tickets about to expire so we can make sure they are used.
A________________B
Expiry Date________Redeemed by
15/08/2014
15/02/2014
15/08/2014________John
15/02/2010________Marc
15/02/2011________Bob
View 4 Replies
View Related
Sep 8, 2009
I’m trying to use the SUMIFS function in Excel 2007 to evaluate the following formula:
{=SUMIFS(range to sum, range to evaluate, evaluation criterion)}
The range to sum is A1:A10, the range (dates) to evaluate are in B1:B10, and the evaluation criterion is that the date is before 31/10/1999.
So my formula looks like this:
{=SUMIFS(A1:A10,B1:B10,”<31/10/1999”)}
This works fine, but how do I refer the 3rd argument in the function to a date in a particular cell rather than typing in the date specifically?
View 2 Replies
View Related
Jan 27, 2013
I am trying to automate a process where a series of numbers would get populated according the range values. Also I am trying to get the automation to pick up the next range when finished with first one and continue with the task.
Here's what I have as start info and where I want to get to.
Sheet1
A
B
1
Ranges
[Code] ......
Excel 2003
View 2 Replies
View Related
Sep 17, 2013
Currently my Macro should: Turn off any filtersNumber column A from 1 to 1000 (starting in A14)Drags formula from K14-O14 down to last row of data shown in column Athen puts cursor in last empty cell in column B ready for user to enter data
On point 3 - I want the range to be K14-O14 if active worksheet equals "EXCHANGES" but if its on the "VALUATIONS" tab the autofill range should be L14-P14
I have found bits and pieces of macros on the internet and put them together so if my macro below is not the most effective for my needs but here it is in it's current state:
Here is my macro:
Sub AddNewEntry()
'TURNS OFF FILTER IF FINDS ONE ON
Dim wks As Worksheet
[Code]....
View 8 Replies
View Related
Mar 25, 2009
I was just recently forced to create my first UDF and after how well it worked I now am very interested in learning more. I am trying to create a function to sort a range by the values in a specific column and return the range. I know this should be really simple but for some reason my code dies whenever it gets to my inner-most loop. I need to use this in a larger function but for now this is my only question. I did find that Excel 2007 has built in Functions for this but my company still uses 2003.
My
Public Function SortRange(rngToSort As Range, valCol As Integer)
Dim Swapper As Variant
Dim i As Integer, _
j As Integer, _
k As Integer
For i = 1 To rngToSort.Rows.Count
For j = 1 To rngToSort.Rows.Count - i
If rngToSort(j + 1, valCol) < rngToSort(j, valCol) Then
For k = 1 To rngToSort.Columns.Count
Swapper = rngToSort(j, k)
rngToSort(j, k) = rngToSort(j + 1, k)
rngToSort(j + 1, k) = Swapper
Next k
End If
Next j
Next i
SortRange = rngToSort
End Function
View 9 Replies
View Related