Sub Test3()
Dim LSearchRow As Integer
Dim LCopyToRow As Integer
On Error GoTo Err_Execute
'Start search in row 5
LSearchRow = 5
'Start copying data to row 2 in Sheet3 (row counter variable)
LCopyToRow = 2
While Len(Range("Y" & CStr(LSearchRow)).Value) > 0
'If value in column Y = "84312570", copy entire row to Sheet3
If Range("Y" & CStr(LSearchRow)).Value = "84312570" Then
'Select row in MasterList to copy
Rows(CStr(LSearchRow) & ":" & CStr(LSearchRow)).Select
Selection.Copy
'Paste row into Sheet3 in next row
Sheets("Sheet3").Select
Rows(CStr(LCopyToRow) & ":" & CStr(LCopyToRow)).Select
ActiveSheet.Paste
'Move counter to next row
LCopyToRow = LCopyToRow + 1
'Go back to MasterList to continue searching
Sheets("MasterList").Select
End If
LSearchRow = LSearchRow + 1
Wend
'Position on cell A5
Application.CutCopyMode = False
Range("A5").Select
MsgBox "All matching data has been copied."
Exit Sub
Err_Execute:
MsgBox "An error occurred."
End Sub
This finds specific values in Column Y and moves entire rows of corresponding information to individual worksheets.
I have two questions.
First, is there a way to specify only certain columns of information be moved to the individual sheets instead of moving the entire row?
Second, is there a way to pull information based off of only the last 4 digits of the number sequence in column Y? For example, above I would want to pull all rows whose number in column Y matched *2570.
Untested: edit arrColsToCopy to include the columns you want copied over