Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm writing a macro that will insert a column, calculate a
formula and then fill the appropriate formula to the end of the column. My problem is the column lentgh varies. So I need to be able to reference a variable range. This is what I have tried. CNT = Range("B1", Range("B1").End(xlDown)).Count Columns("A:A").Select Selection.Insert Shift:=xlToRight Range("A1").Select ActiveCell.FormulaR1C1 = "run" Range("A2").Select ActiveCell.FormulaR1C1 = "=RC[1]" Range("A3").Select ActiveCell.FormulaR1C1 = "=IF(RC[1]<R[-1]C[1]+3,R[-1]C,RC [1])" Range("A3").Select Selection.NumberFormat = "m/d/yy h:mm" Selection.AutoFill Destination:=Range("A3:A249"), Type:=xlFillDefault Columns("A:A").Select Selection.Copy Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False I have changed the range in this code ... Selection.AutoFill Destination:=Range("A3:A249"), Type:=xlFillDefault to Range("A3:A[cnt]") and RC:R[cnt]C with no luck. The column length is going to vary from 100 to 5000. I don't want to set it to A5000 because the data is analyzed further. Thanks, Monica |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Need Macro to autofill formula to last row with data | Excel Discussion (Misc queries) | |||
Automating to autofill column B based on column A entry | Excel Discussion (Misc queries) | |||
Macro to autofill column | Excel Discussion (Misc queries) | |||
Macro that will autofill a column with data, up to the last row of data in previous c | Excel Programming | |||
macro to autofill formula? | Excel Programming |