I recorded the macro below. I would like to change it so instead of the cell range identified, I would like it to run on whatever cells I currently have selected.
Ideally, I would open a workbook with this macro, then open another workbook. In the second workbook I would highlight a range of cells in a column (city names) then run this macro against what I have selected (instead of the cell range the macro recorded).
I thought I saw code that does something like this, but I don't know how to change what I have below.
Thanks for any help you can provided.
Ideally, I would open a workbook with this macro, then open another workbook. In the second workbook I would highlight a range of cells in a column (city names) then run this macro against what I have selected (instead of the cell range the macro recorded).
I thought I saw code that does something like this, but I don't know how to change what I have below.
Thanks for any help you can provided.
Code:
Sub CanadaReplacements()
'
' CanadaReplacements Macro
'
' Keyboard Shortcut: Ctrl+Shift+C
'
Range("A7").Select
Selection.AutoFilter
ActiveSheet.Range("$A$7:$A$100000").AutoFilter Field:=1, Criteria1:="=*'*", _
Operator:=xlAnd
Selection.Replace What:="'", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
ActiveSheet.Range("$A$7:$A$100000").AutoFilter Field:=1, Criteria1:="=*-*", _
Operator:=xlAnd
Selection.Replace What:="-", Replacement:=" ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
ActiveSheet.Range("$A$7:$A$100000").AutoFilter Field:=1, Criteria1:="=E **", _
Operator:=xlAnd
Selection.Replace What:="E ", Replacement:="East ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
ActiveSheet.Range("$A$7:$A$100000").AutoFilter Field:=1, Criteria1:="=E. **", _
Operator:=xlAnd
Selection.Replace What:="E. ", Replacement:="East ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
ActiveSheet.Range("$A$7:$A$100000").AutoFilter Field:=1, Criteria1:="=** Crn", _
Operator:=xlAnd
Selection.Replace What:=" Crn", Replacement:=" Corner", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
ActiveSheet.Range("$A$7:$A$100000").AutoFilter Field:=1
End Sub