Hey
i am getting runtime error 1004 'Application defined or object defined' on running this code can anyone please help... its reallly urgent
Thanks in advance
i am getting runtime error 1004 'Application defined or object defined' on running this code can anyone please help... its reallly urgent
Code:
Private Sub CommandButton2_Click()
Dim torow As Long
Dim lastrow As Long
Dim dayCounter As Integer
Dim i, k As Integer
lastrow = Range("A65").End(xlUp).Row
i = Sheet2.Range("A1:A50").Find("Lever 1", Range("A1"), xlValues, xlWhole, xlByColumns, xlNext).Row
i = i + 1
'For dayCounter = 2 To 32
For k = 1 To (lastrow - 1)
Sheet2.Rows(i).Insert Shift:=xlDown
Next
ActiveWorkbook.Sheets(1).Activate
ActiveWorkbook.Sheets(1).Range(Cells(2, "A"), Cells(lastrow, "A")).Select
ActiveWorkbook.Sheets(1).Range(Cells(2, "A"), Cells(lastrow, "A")).Copy
ActiveWorkbook.Sheets(2).Activate
ActiveWorkbook.Sheets(2).Range(Cells((i - 1), "B"), Cells((i + lastrow - 2), "B")).Select
ActiveWorkbook.Sheets(2).Paste
End Sub
Thanks in advance