I have a workbook which I need to copy rows to a new worksheet. One of the columns is called Vendor. I have 12 different vendors, but 3 of them have different entries. Let's say column "C" is the vendor column and contains the following:
Vendor 1
Vendor 1 Onshore
Vendor 1 Offshore
Vendor 2
Vendor 2 Onshore
Vendor 2 Offshore
Vendor 3
Vendor 4
Vendor 5
What I need to do is copy all Vendor 1's to a new worksheet. So when the value of column "C" is any of the following Vendor 1, Vendor 1 Onshore, or Vendor 1 Offshore it is copied to the new workbook.
I have the following code which of course only works for the entry I input.
Vendor 1
Vendor 1 Onshore
Vendor 1 Offshore
Vendor 2
Vendor 2 Onshore
Vendor 2 Offshore
Vendor 3
Vendor 4
Vendor 5
What I need to do is copy all Vendor 1's to a new worksheet. So when the value of column "C" is any of the following Vendor 1, Vendor 1 Onshore, or Vendor 1 Offshore it is copied to the new workbook.
I have the following code which of course only works for the entry I input.
Code:
Private Sub Workbook_Open()
Dim i, LastRow
Set ws1 = Sheets("Raw Data SP")
Set ws2 = Sheets("Vendor")
LastRow = ws1.Range("A" & Rows.Count).End(xlUp).Row
ws2.Range("A2:S1000").ClearContents
For i = 2 To LastRow
If ws1.Cells(i, "C").Value = "Vendor 1" Then
ws1.Cells(i, "C").EntireRow.Copy Destination:=ws2.Range("A" & Rows.Count).End(xlUp).Offset(1)
End If
Next i
End Sub