VBA Error 1004 application defined or object defined error

rishbajaj

New Member
Joined
May 9, 2012
Messages
1
Sub MoveRows()
Dim rownum As Integer
Dim colnum As Integer
Dim startrow As Integer
Dim endrow As Integer
Dim timerow As Integer

rownum = 1
colnum = 1

Sheet2.Cells.Clear
'Worksheets("Sheet2").Select
With ActiveWorkbook.Worksheets("Sheet1")
Do
Do
If .Cells(rownum, 1).Value = "CUSIP BOND MARKET SIZE" Then
startrow = rownum
End If
rownum = rownum + 1
Loop Until .Cells(rownum, 1).Value = "-------------------------------------------------------------------------------"

endrow = rownum
timerow = startrow
Do
timerow = timerow - 1
Loop Until .Cells(timerow, 1).Value = "----- Original Message -----"
timerow = timerow + 2

ActiveWorkbook.Worksheets("Sheet1").Range(timerow & ":" & endrow).Copy

Worksheets("Sheet2").Select
ActiveWorkbook.ActiveSheet.Paste



Loop Until .Cells(rownum, 1).Value = "END OF DATA"
End With


The error shows on the line
ActiveWorkbook.ActiveSheet.Paste

I have tried adding an unprotect and protect code before and after this line as well. What could be the possible reason??
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,223,909
Messages
6,175,315
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top