View Single Post
 
Old 03-25-2018, 05:38 PM
kevinbradley57 kevinbradley57 is offline Windows 7 64bit Office 2010 64bit
Advanced Beginner
 
Join Date: Jul 2017
Posts: 89
kevinbradley57 is on a distinguished road
Default

NoSparks -- Your code does exactly what I needed, but the "arr(2)" portion it appears to limit the number of names in the cell to two. There could be as many as 10 names in the cell, or as few as none. Can you help with that?

Sub RemoveParenth_2()

Dim rng As Range, cel As Range
Dim lr As Long, arr As Variant

lr = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
Set rng = Union(Range("A1:A" & lr), Range("B1:B" & lr), Range("J1:J" & lr))

For Each cel In rng
If InStr(1, cel.Value, "(") > 0 And InStr(1, cel.Value, ")") > 0 Then
arr = Split(Replace(Replace(cel.Value, "(", "|"), ")", "|"), "|")
cel.Value = Trim(arr(0) & arr(2))
End If
Next cel
End Sub
Reply With Quote