Patrick Rinard
New Member
- Joined
- Jan 20, 2016
- Messages
- 2
Hi,
So I am trying to build a macro to pull data from one sheet in a workbook sorted by the data in column M. I currently have the macro written such that it pulls all of the data over to each of the new sheets and then deleting the info that is not applicable. Unfortunately the deleting is only working of the first sheet once the macro starts running the second sheet I get an error "Run-time error ‘13’ which says Type mismatch". I am not sure what to do to get the sheets after the first one to work the same way. See below for the code as it is currently written.
Sheets("Detail Sorted").Select
Range("A2:M" & Last).Select
Selection.Copy
Sheets("FBPR").Select
Range("A2").Select
ActiveSheet.Paste
For i = 1000 To 1 Step -1
If Cells(i, "M").Value = "RBCC" Or Cells(i, "M").Value = "RBCB" Or _
Cells(i, "M").Value = "FCB" Or Cells(i, "M").Value = "STATE FARM" Or _
Cells(i, "M").Value = "VZCON" Then
Cells(i, 1).EntireRow.Delete
End If
Next i
Sheets("Detail Sorted").Select
Range("A2:M" & Last).Select
Selection.Copy
Sheets("RBCC").Select
Range("A2").Select
ActiveSheet.Paste
For i = 1000 To 1 Step -1
If Cells(i, "M").Value = "FCB" Or Cells(i, "M").Value = "RBCB" Or _
Cells(i, "M").Value = "FBPR" Or Cells(i, "M").Value = "STATE FARM" Or _
Cells(i, "M").Value = "VZCON" Then
Cells(i, 1).EntireRow.Delete
End If
Next i
For i = 1000 To 1 Step -1
If Cells(i, "M").Value = "FCB" Or "RBCB" Or "FBPR" Or "STATE FARM" Or "VZCON" Then
Cells(i, 1).EntireRow.Delete
End If
Next i
Sheets("Detail Sorted").Select
Range("A2:M" & Last).Select
Selection.Copy
Sheets("RBCB").Select
Range("A2").Select
ActiveSheet.Paste
For i = 1000 To 1 Step -1
If Cells(i, "M").Value = "FBPR" Or Cells(i, "M").Value = "RBCC" Or _
Cells(i, "M").Value = "FCB" Or Cells(i, "M").Value = "STATE FARM" Or _
Cells(i, "M").Value = "VZCON" Then
Cells(i, 1).EntireRow.Delete
End If
Next i
Sheets("Detail Sorted").Select
Range("A2:M" & Last).Select
Selection.Copy
Sheets("FCB").Select
Range("A2").Select
ActiveSheet.Paste
For i = 1000 To 1 Step -1
If Cells(i, "M").Value = "FBPR" Or Cells(i, "M").Value = "RBCC" Or _
Cells(i, "M").Value = "RBCB" Or Cells(i, "M").Value = "STATE FARM" Or _
Cells(i, "M").Value = "VZCON" Then
Cells(i, 1).EntireRow.Delete
End If
Next i
Sheets("Detail Sorted").Select
Range("A2:M" & Last).Select
Selection.Copy
Sheets("STATE FARM").Select
Range("A2").Select
ActiveSheet.Paste
For i = 1000 To 1 Step -1
If Cells(i, "M").Value = "FBPR" Or Cells(i, "M").Value = "RBCC" Or _
Cells(i, "M").Value = "RBCB" Or Cells(i, "M").Value = "FCB" Or _
Cells(i, "M").Value = "VZCON" Then
Cells(i, 1).EntireRow.Delete
End If
Next i
Sheets("Detail Sorted").Select
Range("A2:M" & Last).Select
Selection.Copy
Sheets("VZCON").Select
Range("A2").Select
ActiveSheet.Paste
For i = 1000 To 1 Step -1
If Cells(i, "M").Value = "FBPR" Or Cells(i, "M").Value = "RBCC" Or _
Cells(i, "M").Value = "RBCB" Or Cells(i, "M").Value = "FCB" Or _
Cells(i, "M").Value = "STATE FARM" Then
Cells(i, 1).EntireRow.Delete
End If
Next i
So I am trying to build a macro to pull data from one sheet in a workbook sorted by the data in column M. I currently have the macro written such that it pulls all of the data over to each of the new sheets and then deleting the info that is not applicable. Unfortunately the deleting is only working of the first sheet once the macro starts running the second sheet I get an error "Run-time error ‘13’ which says Type mismatch". I am not sure what to do to get the sheets after the first one to work the same way. See below for the code as it is currently written.
Sheets("Detail Sorted").Select
Range("A2:M" & Last).Select
Selection.Copy
Sheets("FBPR").Select
Range("A2").Select
ActiveSheet.Paste
For i = 1000 To 1 Step -1
If Cells(i, "M").Value = "RBCC" Or Cells(i, "M").Value = "RBCB" Or _
Cells(i, "M").Value = "FCB" Or Cells(i, "M").Value = "STATE FARM" Or _
Cells(i, "M").Value = "VZCON" Then
Cells(i, 1).EntireRow.Delete
End If
Next i
Sheets("Detail Sorted").Select
Range("A2:M" & Last).Select
Selection.Copy
Sheets("RBCC").Select
Range("A2").Select
ActiveSheet.Paste
For i = 1000 To 1 Step -1
If Cells(i, "M").Value = "FCB" Or Cells(i, "M").Value = "RBCB" Or _
Cells(i, "M").Value = "FBPR" Or Cells(i, "M").Value = "STATE FARM" Or _
Cells(i, "M").Value = "VZCON" Then
Cells(i, 1).EntireRow.Delete
End If
Next i
For i = 1000 To 1 Step -1
If Cells(i, "M").Value = "FCB" Or "RBCB" Or "FBPR" Or "STATE FARM" Or "VZCON" Then
Cells(i, 1).EntireRow.Delete
End If
Next i
Sheets("Detail Sorted").Select
Range("A2:M" & Last).Select
Selection.Copy
Sheets("RBCB").Select
Range("A2").Select
ActiveSheet.Paste
For i = 1000 To 1 Step -1
If Cells(i, "M").Value = "FBPR" Or Cells(i, "M").Value = "RBCC" Or _
Cells(i, "M").Value = "FCB" Or Cells(i, "M").Value = "STATE FARM" Or _
Cells(i, "M").Value = "VZCON" Then
Cells(i, 1).EntireRow.Delete
End If
Next i
Sheets("Detail Sorted").Select
Range("A2:M" & Last).Select
Selection.Copy
Sheets("FCB").Select
Range("A2").Select
ActiveSheet.Paste
For i = 1000 To 1 Step -1
If Cells(i, "M").Value = "FBPR" Or Cells(i, "M").Value = "RBCC" Or _
Cells(i, "M").Value = "RBCB" Or Cells(i, "M").Value = "STATE FARM" Or _
Cells(i, "M").Value = "VZCON" Then
Cells(i, 1).EntireRow.Delete
End If
Next i
Sheets("Detail Sorted").Select
Range("A2:M" & Last).Select
Selection.Copy
Sheets("STATE FARM").Select
Range("A2").Select
ActiveSheet.Paste
For i = 1000 To 1 Step -1
If Cells(i, "M").Value = "FBPR" Or Cells(i, "M").Value = "RBCC" Or _
Cells(i, "M").Value = "RBCB" Or Cells(i, "M").Value = "FCB" Or _
Cells(i, "M").Value = "VZCON" Then
Cells(i, 1).EntireRow.Delete
End If
Next i
Sheets("Detail Sorted").Select
Range("A2:M" & Last).Select
Selection.Copy
Sheets("VZCON").Select
Range("A2").Select
ActiveSheet.Paste
For i = 1000 To 1 Step -1
If Cells(i, "M").Value = "FBPR" Or Cells(i, "M").Value = "RBCC" Or _
Cells(i, "M").Value = "RBCB" Or Cells(i, "M").Value = "FCB" Or _
Cells(i, "M").Value = "STATE FARM" Then
Cells(i, 1).EntireRow.Delete
End If
Next i