Reputation: 67
How can I trim a the text in each cell in a column?
If the syntax is like: "[email protected] (name name)" and I want to delete "@twitter.com (name name)" from all cells in the column being left with only "blabla" in the cells.
Any ideas?
Upvotes: 0
Views: 4234
Reputation: 9380
You do not need to use VBA to achive this in Excel.
Assuming the your text is in column A, the following formula in an adjacent column for each row will do what you need for your example.
=LEFT(A1,FIND("@",A1)-1)
You may need to elaborate this depending on the input data to account for cases where there is no @ characters in the text.
Upvotes: 1
Reputation: 67
Found a solution:
Dim cellHolder As String
For Each cell In Range("A1:A10")
cellHolder = cell.Value
cellHolder = Left(cellHolder, InStr(cellHolder, "@") - 1)
cell.Value = cellHolder
Next cell
Upvotes: 2