getsatv
04-24-2008, 11:24 PM
Hi Iam very new to Excel Vba iam facing a problem i have recored a macro
which allows me to copy the formula from active cell to last worked cell in the same column but the problem is that its been hardcoded next time i run a macro it runs only from b1 to b5456 but data is actually more than that.
so code should be in such a way that it should check the last worked row in the particular column where i execute the macro.
Here is the code which i have recored
Selection.copy
ActiveCell.Offset(0, 1).Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(-7, -1).Range("A1:A8").Select
ActiveCell.Offset(0, -1).Range("A1").Activate
Range(Selection, Selection.End(xlUp)).Select
ActiveCell.Offset(-5098, 0).Range("A1:A5099").Select (here it gives me run time a error 1004 message)
ActiveCell.Activate
ActiveSheet.Paste
End Sub
which allows me to copy the formula from active cell to last worked cell in the same column but the problem is that its been hardcoded next time i run a macro it runs only from b1 to b5456 but data is actually more than that.
so code should be in such a way that it should check the last worked row in the particular column where i execute the macro.
Here is the code which i have recored
Selection.copy
ActiveCell.Offset(0, 1).Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(-7, -1).Range("A1:A8").Select
ActiveCell.Offset(0, -1).Range("A1").Activate
Range(Selection, Selection.End(xlUp)).Select
ActiveCell.Offset(-5098, 0).Range("A1:A5099").Select (here it gives me run time a error 1004 message)
ActiveCell.Activate
ActiveSheet.Paste
End Sub