I'm trying to switch surename and first name in column B, and put new name into column C.
This bit of vba is working ok.
But I only want this to be done if there are 11 digits in column A in the same row. Column A holds numbers, 11 digits for persons and 9 digits for companys.
Column B holds both person names and company names, and I only want to switch surename/first name on persons.
Tried this:
... but it switches names on ALL cells in B.
Any ideas on how to modify this bit of vba?
This bit of vba is working ok.
But I only want this to be done if there are 11 digits in column A in the same row. Column A holds numbers, 11 digits for persons and 9 digits for companys.
Column B holds both person names and company names, and I only want to switch surename/first name on persons.
Tried this:
Code:
'Check if cell in column A holds 11 digits or not
For Each cell In Range("A2", Range("A" & Rows.Count).End(xlUp))
If Len(cell.Value) = 11 Then
'Switch surname and first name in column B, and place it into column C (code is ok)
With Range("B2", Range("B" & Rows.Count).End(xlUp))
.Offset(, 1).Value = Evaluate(Replace("if(len(#),left(trim(right(substitute(#,"" "",rept("" "",100)),100))&"" ""&#,len(#)),"""")", "#", .Address))
End With
End If
Next cell
... but it switches names on ALL cells in B.
Any ideas on how to modify this bit of vba?