Hi - here is a sample and the entire code for the sample. I took out part of the code out (it didn't have anything to do with the question that I originally asked) or so i thought, as it seemed to be working okay...
Here is the entire code for the sample:
Dim sheetName As Variant
For Each sheetName In Array("Converted", "Lost-missed", "Novartis", "RBS", "RSA")
Sheets(sheetName).Range("A7:XFD1048576").Delete
Next sheetName
Dim erow As Long
Dim w1 As Worksheet
Dim w2 As Worksheet
Set w1 = Sheets("Consolidation")
Set w2 = Sheets("Novartis")
x = 7
Do While Cells(x, 1) <> ""
If Cells(x, 1) = "Novartis" Then
w1.Rows(x).Copy
w2.Activate
erow = w2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=w2.Rows(erow)
End If
Worksheets("Consolidation").Activate
x = x + 1
Loop
Application.CutCopyMode = False
Set w1 = Sheets("Consolidation")
Set w2 = Sheets("RBS")
x = 7
Do While Cells(x, 1) <> ""
If Cells(x, 1) = "RBS" Then
w1.Rows(x).Copy
w2.Activate
erow = w2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=w2.Rows(erow)
End If
Worksheets("Consolidation").Activate
x = x + 1
Loop
Application.CutCopyMode = False
Set w1 = Sheets("Consolidation")
Set w2 = Sheets("RSA")
x = 7
Do While Cells(x, 1) <> ""
If Cells(x, 1) = "RSA" Then
w1.Rows(x).Copy
w2.Activate
erow = w2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=w2.Rows(erow)
End If
Worksheets("Consolidation").Activate
x = x + 1
Loop
Application.CutCopyMode = False
Dim i As Long
Set w1 = Sheets("Consolidation")
Set w2 = Sheets("Converted")
With w1
For i = .Cells(.Rows.Count, "E").End(xlUp).Row To 7 Step -1
If .Cells(i, 5) = "Converted" Then
.Rows(i).Copy w2.Cells(Rows.Count, 1).End(xlUp).Offset(1)
.Rows(i).Delete
End If
Application.CutCopyMode = False
Next
End With
Set w1 = Sheets("Consolidation")
Set w2 = Sheets("Lost-missed")
With w1
For i = .Cells(.Rows.Count, "E").End(xlUp).Row To 7 Step -1
If .Cells(i, 5) = "Lost/Missed" Then
.Rows(i).Copy w2.Cells(Rows.Count, 1).End(xlUp).Offset(1)
.Rows(i).Delete
End If
Application.CutCopyMode = False
Next
End With
End Sub
And the attached workbook too...
Thanks!
Bookmarks