-
Solved: Using for next loop
The code below replaces and moves the strings. Anytime it does not find one of the strings it will skip over the replacement, but it will move the string to the correct destination. I have tried adding in code where if lets say "(HEATHER)" did not exist it would skip that part and go to the next name I wanted to replace. So far I have been unable to get this to work.
Thanks,
gj0519
[VBA]Sub Fix_Names()
With Worksheets(2)
Worksheets(2).Columns(3).Replace _
What:="(HEATHER)", Replacement:="HEATHER", _
Searchorder:=xlByColumns, MatchCase:=True
Range("C1").Select
Selection.Cut Destination:=Range("A6")
End With
With Worksheets(2)
Worksheets(2).Columns(3).Replace _
What:="(JANICE)", Replacement:="JANICE", _
Searchorder:=xlByColumns, MatchCase:=True
Range("C10").Select
Selection.Cut Destination:=Range("A15")
End With
With Worksheets(2)
Worksheets(2).Columns(3).Replace _
What:="(SHERRY)", Replacement:="SHERRY", _
Searchorder:=xlByColumns, MatchCase:=True
Range("C19").Select
Selection.Cut Destination:=Range("A24")
End With
With Worksheets(2)
Worksheets(2).Columns(3).Replace _
What:="(LINDAL)", Replacement:="LINDA", _
Searchorder:=xlByColumns, MatchCase:=True
Range("C28").Select
Selection.Cut Destination:=Range("A33")
End With
With Worksheets(2)
Worksheets(2).Columns(3).Replace _
What:="(CORAL)", Replacement:="CORAL", _
Searchorder:=xlByColumns, MatchCase:=True
Range("C37").Select
Selection.Cut Destination:=Range("A42")
End With
End Sub[/VBA]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules