Hello,
I am trying to modify this vba code that would find rows containing 20 products and cut/paste them onto another sheet. I tried to add an elseif to this code but it is not working. I am new to this so any help would be appreciated.
Sub CopyYes()
Dim c As Range
Dim j As Integer
Dim Source As Worksheet
Dim Target As Worksheet
' Change worksheet designations as needed
Set Source = ActiveWorkbook.Worksheets("Sheet1")
Set Target = ActiveWorkbook.Worksheets("Sheet2")
j = 1 ' Start copying to row 1 in target sheet
For Each c In Source.Range("a1:a1000000") ' Do 1000 rows
If c = "Product1" Then
Source.Rows(c.Row).Copy Target.Rows(j)
j = j + 1
End If
Next c
End Sub
I am trying to modify this vba code that would find rows containing 20 products and cut/paste them onto another sheet. I tried to add an elseif to this code but it is not working. I am new to this so any help would be appreciated.
Sub CopyYes()
Dim c As Range
Dim j As Integer
Dim Source As Worksheet
Dim Target As Worksheet
' Change worksheet designations as needed
Set Source = ActiveWorkbook.Worksheets("Sheet1")
Set Target = ActiveWorkbook.Worksheets("Sheet2")
j = 1 ' Start copying to row 1 in target sheet
For Each c In Source.Range("a1:a1000000") ' Do 1000 rows
If c = "Product1" Then
Source.Rows(c.Row).Copy Target.Rows(j)
j = j + 1
End If
Next c
End Sub