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??
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??