Hi,
I've got some cells that contain names and numbers within parentheses. (the cells located in the A column, starting on cell 2)
I only want to keep the names, so I want to delete the parentheses and everything in them.john(5)
jack(90)
joe(120)
Since the parentheses is always last in a cell, my vba function should find the first parenthesis, and then delete it and everything that comes afterwards.
I've figured out that i can use 'InStr' to check if the cell contains a parenthesis.
But I need some help with the deleting part.
Public Sub DelEverythingAfterParenthesis()
Dim rngCell As Range
Set ws = Workbooks("a.xls").Sheets("sheet1")
For Each rngCell In ws.Range(Cells(2, "A"), ws.Cells(Rows.Count, "A").End(xlUp)).Cells
If (InStr(rngCell, "(") > 0) Then
//Some code to delete the parentheses and everything after it.
End If
Next rngCell
End Sub
Bookmarks