Autofill With Formula: Variable Lengths
Oct 3, 2007
need to autofill collum C with a formula related do collum B. If I do this by hand I just type the formula in C 1, and click on the right-down corner of the cell selection, and the formula goes until the last line (last value on collum B). But I want to create a macro to this function, and the problem is that the files that I will apply the macro have different lengths. I want to modify the macro to be able to run from C1 until the end of the values on collum B. I don't want to freeze the last value.
Here is the macro
Sub Macro3()
ActiveCell.FormulaR1C1 = "=60000/RC[-1]"
Range("C1").Select
Selection.AutoFill Destination:=Range("C1:C4819")
Range("C1:C4819").Select
Range("E7").Select
End Sub
In other files C4819 will not be the last value, could be 5345 for example, but its impossible to do this, my macro should do: "autofill collum C with a formula until the last value on collum B"
View 9 Replies
ADVERTISEMENT
Apr 18, 2007
I need to copy cells M6 to S6 down to all rows in a worksheet. The columns will remain M to S. The number of rows however vary in each worksheet.
How do I get the macro to read "End Down" with varying number of rows. I will need to do other functions also using "End Down" so if possible is there a generic code for this.
View 9 Replies
View Related
Jan 29, 2014
I need to separate the text in "A" to "B" & "C", however, the length of "A" varies. Here's an example.
A
B
C
172.31.39.64 255.255.255.192
172.31.39.64
255.255.255.192
[Code] ....
View 4 Replies
View Related
Apr 4, 2008
I am trying to autofill dynamic ranges that have column variables (d) and row variables (x)... I am having a hard time with the syntax on this
View 9 Replies
View Related
Feb 28, 2009
Say I am downloading a column of stock prices and it cannot be predicted precisely how many rows will be contained in each downloaded column.
The column is, however, always Column E.
Two formulas must be computed.
1) Last row with a price in column E / average (all rows, beginning with row 2 with prices in column E)
2) Last row with a price in column E / average (last 50 rows with prices in column E)
Can Excel manage the variable number of rows required for these formula, and if so, can somebody recommend how to write these formulae?
View 11 Replies
View Related
Aug 30, 2009
I have the following code that was achieved using the macro recorder. The only problem I am running into is that during the autofill command, there are never the same amount of rows to autofill. It could be as few as 5 rows and as many as there are rows on the spreadsheet. When I recorded the macro there were 953 lines, and unfortunately I cannot figure out how to change the specific destination of 953 to a variable destination determined by when data ends. Here is the code I currently have:
View 5 Replies
View Related
Jul 9, 2014
The cells A2:A25 are merged in my excel sheet and I would like to create subsequent merged cells below the A2:A25 set; however, I would like the user to determine the number of merged cell boxes.
The code I have written is as follows:
Dim lr As Long
lr = Application.InputBox("How many days was the monitor deployed?", Type:=2)
If lr = 0 Then Exit Sub Else lr = lr
Range("A2:A25").Select
Selection.AutoFill Destination:=Range("A2:A" & lr * 24), Type:=xlFillDefault
Range("A2:A" & lr * 24).Select
End Sub
So I am creating a macro where the user opens a message box and types in a value representing the number of days. That value is then calculated into an autofill equation but I keep getting an error.
View 7 Replies
View Related
Nov 1, 2006
I have worksheets that refernce values in one column off columns in others and do this on daily basis. each day there are blank amounts in random fields which I inturn use a macro to delete rows with blank amounts
I then want to autofill the numbers from 0001 to the bottem line of the sheet where the word "END" always is, as the position of the end word is random each time and autofill always needs a definite range how do I get my macro to autofill down to the word "end" ?
here is the code that doesnt work for me and I've been trying to fix
Sub Macro1()
For counter = 1 To 30
Set curCell = Worksheets("Sheet1").Cells(counter, 6)
If curCell.Text = "END" Then Range(Cells(1, 6), Cells(counter-1, 6)). _
Selection.DataSeries Rowcol:=xlColumns, Type:=xlAutoFill, Date:=xlDay, _
Trend:=False
Next counter
End Sub
View 3 Replies
View Related
Oct 12, 2007
I am creating a loop that will autofill 16 cells down. It copies the formula from one cell (Z230), pastes that 16 cells down (cell Z246), then changes the lock properties of the cell (Z246) before autofilling down 16 (to cell Z261). At which point the loop starts over again. (copies cell Z246,pastes it to Z262, fills down 16 , etc)
Because the cell I am copying from changes in each loop, I set a variable to grab the address of the starting cell and last cell of the copy.
I then put this into a String so it would return something like this
Range("Z245:Z259")
Problem is I get extra quotes around Range("Z245:Z259") - it comes out as string "Range("Z245:Z259")"
This gives me a problem when I try to replace
Selection.AutoFill Destination:=Range("Z245:Z246"), Type:=xlFillDefault
with
Selection.AutoFill Destination:=rangevariable, Type:=xlFillDefault
Below is my total code, but I get stuck on the selection line. I have to do this 300 times so I would prefer not to do it manually!
View 9 Replies
View Related
Jan 20, 2008
What I need to be able to achieve is a function in my macro that will
a: Count the number of rows in the active sheet
b: Allow me to use this info in other functions, such as subtotals, autofills
After searching many sites I'm pretty certain the function I need to use is "rowcount".
I've managed to incorporate a loop using this function, which is fine when running the macro but not so good when you are stepping through 5000+ rows
RowCount = ActiveSheet.UsedRange.Rows.Count
For x = 2 To RowCount
Cells(x, 42).Select
ActiveSheet.Paste
Next x
So for me now it seems as though "x" should represent the number of row that has been counted in the above code. But when I try to use "x" in functions the macro falls over
Range("AQ2:AX2").Select
Selection.AutoFill Destination:=Range("R2C43:RxC50")
View 3 Replies
View Related
Aug 7, 2007
Just a niggling problem, I've got lstRow as a Long and it contains the value of the last row offset by (1, 0). The problem is i'm trying to add it into a range
Range("C500:K500").Select
Selection.autofill Destination:=Range(C" & lstRow &":K" & lstRow &")Type:=xlFillDefault
Like that.. Except i've tried a million different combinations of " and & in different places to try and get it to compile. It refuses too. It always gives the error "Expected list seperator or )" I know I could just do it individually from C to K but I'd like to learn how to do it this way as well.
View 6 Replies
View Related
May 13, 2006
I'll do what I can to explain this mess I want to clear up...I have a series of excel reports I have to download and work thru daily and I need to see if there is a code to autofill down thru a column, based on multiple statements throughout the column..here goes:
f1 msp
f2 msp
f3 blank **
f4 mct
f5 mct
f6 mct
f7 blank **
f8 cci
f9 blank **
Regardless of the actual f cell, I always will need to fill the Blank ** cell w/ the values from the previous cell....Hope this makes sense...& thanks in advance....
have_a_cup@cox.net
View 5 Replies
View Related
Feb 19, 2010
I am trying to write a macro which will autofill specific columns. The macro will set the range from the start of my autofill to the end of my autofill as a constant range.
The problem I need to get around is the end of my range can always change each time I run the macro. For instance, the first time I run the macro I may only need to autofill from row 4 to row 15. The next time, I may only need to autofill from row 4 to 23 (because of user updates). How can I make the end of my range not be a constant address but variable?
View 6 Replies
View Related
May 4, 2009
I have the following formula that I would like to be able to autofill.
=UniqueItem('Divide Outs'!$A$2:$A$999,1)
The 1 after the comma needs to count up...anyway to autofill a formula like this?
This is a function that i use to display unique listings.
View 3 Replies
View Related
Mar 29, 2007
I have data in colA. In colB I want to auto fill a formula that is in cell B1 all the way down and stop when the data in A stops.
Range("A1").AutoFill Destination:=Range("B1:B" & Range("B1").End(xlDown).Row)
It doesnt seem to like this though and I think ive got the cols all wrong in the formula.
View 4 Replies
View Related
Jul 18, 2012
I have the macro to insert a formula and copy it in a range("A2:A14", but I want the end of the range in column A to be the last row with data in column B. How to add that in?
Sub vlookup()
Range("A2").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[1],'[Old.xlsx]Total Student Count Data'!R2C2:R1000C2,1,FALSE)"
Range("A2").Select
Selection.autofill Destination:=Range("A2:A14"), Type:=xlFillDefault
Range("A2:A14").Select
End Sub
View 2 Replies
View Related
Aug 1, 2012
The code below inserts a formula into E2, copies it across to column O and then down to the last row. It works fine but if more columns are added obviously it would need to be changed to go up to column P for example.
How can I change this so that the formula will be copied across to the last column automatically and therefore the code will not need to be changed?
Code:
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
Range("E2").Select
[Code]....
View 2 Replies
View Related
Jan 4, 2008
I am trying to use autofill over a range of cells.
I am using a Do While loop to find an empty column in row 6 incremented by 5 based on LFound. The starting value of LColumn is 9 and is increased based on and IsEmpty condition.
Do While LFound = False
LColumn = 9
If IsEmpty(Cells(6, LColumn).Value) = True Then
LFound = True
Else
LColumn = LColumn + 5
End If
Loop
Next I want use this column index to put an equation in a cell
Cells(15, LColumn).Formula = "='" & SheetName & "'!C103"
Last I want to autofill the 8 cells below the refrenced cell.
Cells(15, LColumn).Select
Selection.AutoFill Destination:=Range(Cells(15, LColumn) & ":" & Cells(23, LColumn)),
Type:=xlFillValues
But I can't get the autofill to work. I think it is because of my attempt at going from Cells() to Range(),
View 3 Replies
View Related
Mar 8, 2013
I'm trying to autofill "vertically" in a spreadsheet using a formula which loads value from a different sheet.
Lets say I have cell (A1 for example) ='2013'!A39
Now I want to fill A2-A30 in a way that the formula updates to ='2013'!B39, ='2013'!C39, ='2013'!D39...and so on
I've tried using ='2013'!A$39, but this only copies the formula as it is. When I try to autofill cell A2-A30, the formula still is ='2013!A$39
Is this possible to do?
View 1 Replies
View Related
Jul 3, 2009
I have an xls with over 500 rows of data, every day I have to update the contents of some of the cells, Cell A contains the date and is auto filled already to the end of 2009, Cell B shows me the number of days since I began the sheet and is also auto filled already to the end of 2009, Cell C & Cell D I have to manually enter data
Cell E contains this formula =D527-D526
Cell F =C527/B526
Cell G = =IF(C527=0,0,C527-C526)
Cell H resorts to manual entry.
My question is "why do these columns with formulas, (E,F & G) not automatically carry the formula to the next row?" I'm sure that they once did. Is it a setting that I can't find?
This is excel 2007.
View 6 Replies
View Related
Dec 9, 2013
I am trying to auto fill this formula down a column but it doesn't keep the C4,D4,E4...ETC to stay constant
I manually did these two correct ones
=SUM(C5*C4+D5*D4+E5*E4+F5*F4+G5*G4+H5*H4+I5*I4+J5*J4+K5*K4+L5*L4+M5*M4+N5*N4
+O5*O4+P5*P4+Q5*Q4+R5*R4+S5*S4+T5*T4+U5*U4+V5*V4+W5*W4+X5*X4+Y5*Y4+Z5*Z4+AA5*AA4)
=SUM(C6*C4+D6*D4+E6*E4+F6*F4+G6*G4+H6*H4+I6*I4+J6*J4+K6*K4+L6*L4+M6*M4+N6*N4
+O6*O4+P6*P4+Q6*Q4+R6*R4+S6*S4+T6*T4+U6*U4+V6*V4+W6*W4+X6*X4+Y6*Y4+Z6*Z4+AA6*AA4)
when I drag it down it incorrectly looks like this:
=SUM(C7*C6+D7*D6+E7*E6+F7*F6+G7*G6+H7*H6+I7*I6+J7*J6+K7*K6+L7*L6+M7*M6+N7*N6
+O7*O6+P7*P6+Q7*Q6+R7*R6+S7*S6+T7*T6+U7*U6+V7*V6+W7*W6+X7*X6+Y7*Y6+Z7*Z6+AA7*AA6)
I want C6,D6,E6 to be C4,D4,E4 ETC
View 3 Replies
View Related
May 3, 2007
I have two formulas which I'm using: =180*(120.5-1)/119.5 and =90*(60.5-1)/59.5
In the first example, I want to replicate the formula across row 1, but with the value '1' incrementing by 1 each time, upto 240.
In the second example I want the '1' value to also increase by 1 for each cell down column B, up to 120. when I try dragging the formula down or across, I am only able to replicate the formula exactly as in the initial cell (ie. the '1' doesn't change). I've tried using the $ symbol, but this doesn't work. I don't fancy doing this manually for a total of 360 cells!
View 5 Replies
View Related
Jun 7, 2007
I have two worksheets in the same workbook. In Sheet1, I've got a whole bunch of stuff that I need listed, like names, addresses, phone numbers, etc. What I want to do is pull the values of only the names, which are listed every 42 spots, and put them into a list on Sheet2. So, for example, in Sheet1, A1 is a name, A43 is a name, A85 is a name, etc. In Sheet2, I want to list only the names. And if there isn't a name yet, I want a blank cell. I've sorta figured out how to do it, but I get a problem with the values not incrementing correctly.
So, example code would be
=IF(ISBLANK(SHEET1!A1),"",A1)
=IF(ISBLANK(SHEET1!A43),"",A43)
etc.
The problem is when I drag the auto fill, the next values it gives are
=IF(ISBLANK(SHEET1!A3),"",A3)
=IF(ISBLANK(SHEET1!A44),"",A44)
Instead of the
=IF(ISBLANK(SHEET1!A85),"",A85)
=IF(ISBLANK(SHEET1!A127)"",A127)
....
that I want it to give.
is there anyway to get the values to go up like I want them to, or do I have to enter them all individually? That would really not be fun for me, so I hope that's not the case.
View 4 Replies
View Related
Jan 20, 2008
Here is my test example I am trying to figure this out with.
Sub a()
Dim rg As Range
'set formulas to be filled
Range("A1").Select
ActiveCell.FormulaR1C1 = _
"=IF('sheet2'!RC="""","""",'sheet2'!RC)"
Selection.AutoFill Destination:=Range("A1:L1"), Type:=xlFillDefault
'now get autofill to populate until no more data on sheet 2
Set rg = [a2]
Set rg = Range(rg, Cells(Rows.Count, rg.Column).End(xlUp))
rg.Cells(2, 2).AutoFill Destination:=rg, Type:=xlFillDefault
End Sub
Without VBA, once I set the formulas for A1:L1, I can use the mouse to autofill all columns until Im around row 27,000.
Id like to be able to run a check for the end of data in sheet 2 so that if the sheet2 changes, it will all be included.
The resulting sheet1 cannot have any null values, so a perfect end of data check is necessary.
View 9 Replies
View Related
Jul 30, 2009
Copy and paste the formula into a range or paste a formula into the first cell in the range and autofill down for remainder of cells?
P.S. when autofilling down, can I specify somehow for it to stop at the last row with data in adjacent cell?
View 9 Replies
View Related
Sep 2, 2013
I am using Windows 7, with Excel 2010.
I have one Worksheet Short Course - PB's Which contains all swimmer information and searches through all previous swims and reports back the swimmers current Personal best times (PB)
I am creating a work sheet to calculate percentage increases over a set date period. I have managed the calculations but can not get the autofill to function as I was hoping.
In my short course sheet 1 Row = a Swimmer and there details
In my new sheet, I have 3 rows for the same swimmer
Row 1= Swimmer and PB's before a set date
Row 2 = Swimmer and PB's After set date and upto Todays date
Row 3 = Percentage calculation of difference between the two rows to enable track performance increase
I have all of this working and in place and want to copy the formula's down now to cover all swimmers in the club.
When I copy the 3 lines down, Autofill adds 3 to the row reference for the first line and I just want it to add 1.
ROW3) =IF('Short Course - PB''S'!A3="","",'Short Course - PB''S'!A3)
ROW4) =A3
ROW5) = A3
[Code].....
View 4 Replies
View Related
May 20, 2009
I have a given length of steel bar...Example(550 feet)
I have various cut lengths that I can pick from...
14'-10".....13'- 9".. 12'-8"........(up to 6 different lengths)
I need to know the best combination of lengths to cut the long bar into to have minimal scrap left when we get to the end of the 550 feet.....
Cut as many of the longest cut lengths possiable.....Cut as few of the shortest cut lengths possiable
Due to the fact that I will have to convert this to a PLC application when completed, I want to find a mathmatical way to do this inside excel and not use the "solver"....Assuming that I/we can come up with an equation to do this .....
View 14 Replies
View Related
Aug 18, 2009
I have 4 lengths in four columns in a random order, and need to compare them to see whether they are equal lengths.
I Have figured out how to order them so I can compare them, but can't think of a formula to show whether they are equivilent (eg 1000m = 1km) True or False outcome is fine.
View 3 Replies
View Related
Oct 15, 2009
I have three columns, one column is time every two seconds with data associated that time, and one is time every minute with an associated tidal height.
I want to sort my data so that for every 2 seconds I have an associated tidal height for that minute.
eg:
what I have:
Time Time Tidal Height
(2 sec intervals) (min) (meters)
1:15:00 1:15 1.342
1:15:02 1:16 1.221
1:15:04 1:17 1.115
...
1:15:58 1:43 0.024
1:15:60 1:44 0.012
1:16:00 1:45 0.008 ....................
View 2 Replies
View Related
Aug 19, 2014
I have a performance extract from a system which has performance for multiple accounts but the data is off different lengths and shown vertically. I wish to move the data onto a new sheet but rotated(transposed) horizontally
Attached is a snapshot of the report that is usually about 20,000 lines. See input and output tabs.
Is there any way that a macro could be created to do this.
Performance.xlsx
View 3 Replies
View Related