Sub sample()
Dim myCell As Variant
Application.ScreenUpdating = False
myCell = Range("M2", Cells(Rows.Count, "M").End(xlUp))
For i = 1 To UBound(myCell, 1)
str0 = myCell(i, 1)
str0 = Replace(str0, "1", "A", compare:=vbTextCompare)
str0 = Replace(str0, "2", "b", compare:=vbTextCompare)
str0 = Replace(str0, "3", "C", compare:=vbTextCompare)
str0 = Replace(str0, "4", "d", compare:=vbTextCompare)
str0 = Replace(str0, "0", "X", compare:=vbTextCompare)
myCell(i, 1) = str0
Next
Range("M2", Cells(Rows.Count, "M").End(xlUp)) = myCell
Application.ScreenUpdating = True
End Sub
----------------------------------------------------------------------------
東京( )区・市、埼玉、千葉、神奈川、その他
このような記入方法で入力された住所を置換する。
○○市や〇〇区は東京、東京は東京、埼玉は埼玉、千葉は千葉・・・
H列の値をO列に返している。
Public Sub 住所置換()
Application.ScreenUpdating = False
Dim rg As Range
Dim r As Range
Set rg = Range("H2:H" & Cells(Rows.Count, "A").End(xlUp).Row)
For Each r In rg
If Right(r.Value, 1) = "区" Or Right(r.Value, 1) = "市" Then
r.Offset(, 7).Value = "東京"
Else
r.Offset(, 7).Value = r.Value
End If
Next
Application.ScreenUpdating = True
End Sub