Got a list of addresses, but there are ~600 that need a comma "," after the last name(?) and before the post code.
At the moment, the manual process is (for each entry);
* F2
* Ctrl+left x2
* Left x1
* Comma
* Enter.
Did try recording a macro - no joy.
Any ideas?
Need to insert a ","
-
- Administrator
- Posts: 78391
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Need to insert a ","
Test the following on a copy of your list first.
------------------
Select the list.
Run the following macro:
------------------
Select the list.
Run the following macro:
Code: Select all
Sub AddComma()
Dim rng As Range
Dim a() As String
Dim n As Long
Application.ScreenUpdating = False
For Each rng In Selection
a = Split(rng.Value)
n = UBound(a)
If n >= 2 Then
If Right(a(n - 2), 1) <> "," Then
a(n - 2) = a(n - 2) & ","
rng.Value = Join(a)
End If
End If
Next rng
Application.ScreenUpdating = True
End Sub
Best wishes,
Hans
Hans
-
- StarLounger
- Posts: 93
- Joined: 10 Oct 2019, 09:43
Re: Need to insert a ","
Looks like that's done it.
Thank you
Thank you