String help
Hi Ramthebuffs,
Try this to see if it's what you want. It assumes you will manually select
the cells that you want trimmed. You could modify that to reference a range.
Sub TrimString()
' Trims unwanted characters from a text string
Dim iPos1 As Integer, iPos2 As Integer, j As Long
Dim rngTextToTrim As Range
Set rngTextToTrim = Selection
For j = 1 To Selection.Cells.Count
With rngTextToTrim
Do
iPos1 = InStr(1, .Cells(j), " (", vbTextCompare)
If iPos1 = 0 Then Exit Do
iPos2 = InStr(1, .Cells(j).Value, ")", vbTextCompare)
.Cells(j).Value = Left$(.Cells(j).Value, iPos1 - 1) &
Mid$(.Cells(j).Value, iPos2 + 1)
Loop
End With
Next
End Sub
HTH
Regards,
GS
|