O
Outatym
I am needing to search column G on the "Master" sheet for certain states
starting at row 3. If if finds the correct state, say AR, then I need it to
copy that entire row and paste it into another worksheet. Here is the code I
am working with:
***********************************************************
Sheets("Master").Activate
For i = 3 To Cells(Rows.Count, 7).End(xlUp).Row
If Cells(i, 7).Text = "AR" Then
Selection.EntireRow.Copy
Worksheets("Ed").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "TN" Then
Selection.EntireRow.Copy
Worksheets("Beverly").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "IL" Then
Selection.EntireRow.Copy
Worksheets("Kevin").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "GA" Then
Selection.EntireRow.Copy
Worksheets("Chris E").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "SC" Then
Selection.EntireRow.Copy
Worksheets("Chris E").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "IN" Then
Selection.EntireRow.Copy
Worksheets("David F").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "OH" Then
Selection.EntireRow.Copy
Worksheets("David F").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "PA" Then
Selection.EntireRow.Copy
Worksheets("David F").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "MI" Then
Selection.EntireRow.Copy
Worksheets("Louise").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "MO" Then
Selection.EntireRow.Copy
Worksheets("Louise").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "VA" Then
Selection.EntireRow.Copy
Worksheets("Louise").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "AL" Then
Selection.EntireRow.Copy
Worksheets("Bunny").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "MS" Then
Selection.EntireRow.Copy
Worksheets("Bunny").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "FL" Then
Selection.EntireRow.Copy
Worksheets("Bunny").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
Next
***********************************************************
But for some reason it will only find CA and paste mutiple copies of that
row. I've apparently gotten something screwed up here....
starting at row 3. If if finds the correct state, say AR, then I need it to
copy that entire row and paste it into another worksheet. Here is the code I
am working with:
***********************************************************
Sheets("Master").Activate
For i = 3 To Cells(Rows.Count, 7).End(xlUp).Row
If Cells(i, 7).Text = "AR" Then
Selection.EntireRow.Copy
Worksheets("Ed").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "TN" Then
Selection.EntireRow.Copy
Worksheets("Beverly").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "IL" Then
Selection.EntireRow.Copy
Worksheets("Kevin").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "GA" Then
Selection.EntireRow.Copy
Worksheets("Chris E").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "SC" Then
Selection.EntireRow.Copy
Worksheets("Chris E").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "IN" Then
Selection.EntireRow.Copy
Worksheets("David F").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "OH" Then
Selection.EntireRow.Copy
Worksheets("David F").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "PA" Then
Selection.EntireRow.Copy
Worksheets("David F").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "MI" Then
Selection.EntireRow.Copy
Worksheets("Louise").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "MO" Then
Selection.EntireRow.Copy
Worksheets("Louise").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "VA" Then
Selection.EntireRow.Copy
Worksheets("Louise").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "AL" Then
Selection.EntireRow.Copy
Worksheets("Bunny").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "MS" Then
Selection.EntireRow.Copy
Worksheets("Bunny").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
If Cells(i, 7).Text = "FL" Then
Selection.EntireRow.Copy
Worksheets("Bunny").Activate
Rows("3").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False
End If
Next
***********************************************************
But for some reason it will only find CA and paste mutiple copies of that
row. I've apparently gotten something screwed up here....