SpeedyKevin
New Member
- Joined
- Apr 26, 2019
- Messages
- 17
Hey All!
I'm in need of help on this macro. What I have it doing is searching the sheet for certain things and copying them over to another sheet. However it copies the entire row (which isn't needed) and I was hoping I could just set it to copy the first 3 columns of that row.
The macro is below
The area I think that needs changing is in Red.
Thanks!
Kevin
'Start search in row 1 in Sheet1
LSearchRow = 1
'Start copying data to row 1 in Red (row counter variable)
LCopyToRow = 1
While Len(Range("A" & CStr(LSearchRow)).Value) > 0
'If value in column C = "RED", copy entire row to CopySheet
If Range("C" & CStr(LSearchRow)).Value = "RED" Then
'Select row in Sheet1 to copy
Rows(CStr(LSearchRow) & ":" & CStr(LSearchRow)).Select
Selection.Copy
'Paste row into RED in next row
Sheets("RED").Select
Rows(CStr(LCopyToRow) & ":" & CStr(LCopyToRow)).Select
ActiveSheet.Paste
'Move counter to next row
LCopyToRow = LCopyToRow + 1
'Go back to Sheet1 to continue searching
Sheets("Sheet1").Select
End If
LSearchRow = LSearchRow + 1
Wend
I'm in need of help on this macro. What I have it doing is searching the sheet for certain things and copying them over to another sheet. However it copies the entire row (which isn't needed) and I was hoping I could just set it to copy the first 3 columns of that row.
The macro is below
The area I think that needs changing is in Red.
Thanks!
Kevin
'Start search in row 1 in Sheet1
LSearchRow = 1
'Start copying data to row 1 in Red (row counter variable)
LCopyToRow = 1
While Len(Range("A" & CStr(LSearchRow)).Value) > 0
'If value in column C = "RED", copy entire row to CopySheet
If Range("C" & CStr(LSearchRow)).Value = "RED" Then
'Select row in Sheet1 to copy
Rows(CStr(LSearchRow) & ":" & CStr(LSearchRow)).Select
Selection.Copy
'Paste row into RED in next row
Sheets("RED").Select
Rows(CStr(LCopyToRow) & ":" & CStr(LCopyToRow)).Select
ActiveSheet.Paste
'Move counter to next row
LCopyToRow = LCopyToRow + 1
'Go back to Sheet1 to continue searching
Sheets("Sheet1").Select
End If
LSearchRow = LSearchRow + 1
Wend