Hello all,
I am using the below code to copy specific cell values and paste the entire row into a new worksheet. I am having trouble finishing the code. After the last ElseIf statement i want to add another ElseIf or Else (not sure which one i would use) that will move the rest of the data into its own worksheet.
Does anyone know how to add this statement into the code below?
Sub CopyPasteRows()
a = Worksheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To a
If Worksheets("Sheet2").Cells(i, 14).Value = "Wc" Then
Worksheets("Sheet2").Rows(i).Copy
Worksheets("Sheet3").Activate
b = Worksheets("Sheet3").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Sheet3").Cells(b + 1, 1).Select
ActiveSheet.Paste
Worksheets("Sheet2").Activate
ElseIf Worksheets("Sheet2").Cells(i, 14).Value = "ETOF" Then
Worksheets("Sheet2").Rows(i).Copy
Worksheets("Sheet3").Activate
b = Worksheets("Sheet3").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Sheet3").Cells(b + 1, 1).Select
ActiveSheet.Paste
Worksheets("Sheet2").Activate
End If
Next
Application.CutCopyMode = False
ThisWorkbook.Worksheets("Sheet2").Cells(1, 1).Select
End Sub
I am using the below code to copy specific cell values and paste the entire row into a new worksheet. I am having trouble finishing the code. After the last ElseIf statement i want to add another ElseIf or Else (not sure which one i would use) that will move the rest of the data into its own worksheet.
Does anyone know how to add this statement into the code below?
Sub CopyPasteRows()
a = Worksheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To a
If Worksheets("Sheet2").Cells(i, 14).Value = "Wc" Then
Worksheets("Sheet2").Rows(i).Copy
Worksheets("Sheet3").Activate
b = Worksheets("Sheet3").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Sheet3").Cells(b + 1, 1).Select
ActiveSheet.Paste
Worksheets("Sheet2").Activate
ElseIf Worksheets("Sheet2").Cells(i, 14).Value = "ETOF" Then
Worksheets("Sheet2").Rows(i).Copy
Worksheets("Sheet3").Activate
b = Worksheets("Sheet3").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Sheet3").Cells(b + 1, 1).Select
ActiveSheet.Paste
Worksheets("Sheet2").Activate
End If
Next
Application.CutCopyMode = False
ThisWorkbook.Worksheets("Sheet2").Cells(1, 1).Select
End Sub
Last edited: