PDA

View Full Version : Autofill column to last row



hardcoremark
01-23-2013, 02:33 PM
Hi,

I have recorded a macro, part of which includes inserting a line of text in the first cell of a column and then copying it down to correspond with the last row of text contained within other columns. So the code I have at the moment is as follows;



ActiveCell.FormulaR1C1 = "Upcoming Releases"
Range("I1").Select
Selection.AutoFill Destination:=Range("I1:I200")
Range("I1:I200").Select


The problem is that the last row of text in the other columns is always different. How can I change the code so that it automatically fills to the last row?

Thanks,
Mark.

CodeNinja
01-23-2013, 02:38 PM
ActiveCell.FormulaR1C1 = "Upcoming Releases"
Range("I1").Select
Selection.AutoFill Destination:=Range("I1:I" & activesheet.range("I65536").end(xlup).row)
Range("I1:I"activesheet.range("I65536").end(xlup).row).Select
selection.autofill destination:=range("I1:I" & activesheet.range("I65536").end(xlup).row)

hardcoremark
01-23-2013, 03:10 PM
Thanks for your help. I'm getting a Compile Error: Syntax Error on this line.



Range("I1:I"activesheet.range("I65536").end(xlup).row).Select

CodeNinja
01-23-2013, 04:25 PM
Thanks for your help. I'm getting a Compile Error: Syntax Error on this line.



Range("I1:I"activesheet.range("I65536").end(xlup).row).Select


Sorry in haste I forgot to put an ampersand.... that line should be:

Range("I1:I" & ActiveSheet.Range("I65536").End(xlUp).Row).Select