V
Vlad999
Hi i have been using this macro to cut and paste data from one sheet to
another when i run the macro the first time it works fine but then i
run the macro the second time the macro over rides my data how do i
make it so that data is pasted into the next available blank row in
sheet 2
Code:
--------------------
Sub SearchForString()
Dim LSearchRow As Integer
Dim LCopyToRow As Integer
On Error GoTo Err_Execute
'Start search in row 4
LSearchRow = 2
'Start copying data to row 2 in Sheet2 (row counter variable)
LCutToRow = 2
While Len(Range("F" & CStr(LSearchRow)).Value) > 0
If Range("F" & CStr(LSearchRow)).Value = "RG Complete" Then
Rows(CStr(LSearchRow) & ":" & CStr(LSearchRow)).Select
Selection.Cut
Sheets("Sheet2").Select
Rows(CStr(LCutToRow) & ":" & CStr(LCutToRow)).Select
ActiveSheet.Paste
LCutToRow = LCutToRow + 1
'Go back to Sheet1 to continue searching
Sheets("Sheet1").Select
End If
LSearchRow = LSearchRow + 1
Wend
'Position on cell A3
Application.CutCopyMode = False
Application.ScreenUpdating = False
Range("F2").Select
MsgBox "All RG Complete data has been copied."
Call macro DeleteBlankRows
Exit Sub
Err_Execute:
MsgBox "An error occurred."
End Sub
another when i run the macro the first time it works fine but then i
run the macro the second time the macro over rides my data how do i
make it so that data is pasted into the next available blank row in
sheet 2
Code:
--------------------
Sub SearchForString()
Dim LSearchRow As Integer
Dim LCopyToRow As Integer
On Error GoTo Err_Execute
'Start search in row 4
LSearchRow = 2
'Start copying data to row 2 in Sheet2 (row counter variable)
LCutToRow = 2
While Len(Range("F" & CStr(LSearchRow)).Value) > 0
If Range("F" & CStr(LSearchRow)).Value = "RG Complete" Then
Rows(CStr(LSearchRow) & ":" & CStr(LSearchRow)).Select
Selection.Cut
Sheets("Sheet2").Select
Rows(CStr(LCutToRow) & ":" & CStr(LCutToRow)).Select
ActiveSheet.Paste
LCutToRow = LCutToRow + 1
'Go back to Sheet1 to continue searching
Sheets("Sheet1").Select
End If
LSearchRow = LSearchRow + 1
Wend
'Position on cell A3
Application.CutCopyMode = False
Application.ScreenUpdating = False
Range("F2").Select
MsgBox "All RG Complete data has been copied."
Call macro DeleteBlankRows
Exit Sub
Err_Execute:
MsgBox "An error occurred."
End Sub