I have a slew of rows (100K+) to search and modify the contents.
For example the cells contain similiar text as DGC9610411:DB:10:82
All of this text can change per row except that fact that the : means something to me.
In this and every other row, i need to remove the first : and all the text after so that the cell would look like this DGC9610411
Next I will be adding the contents of another cell to the end. I think that will be an easy step and I could most likely figure that out without much effort.
I have this code in a while loop for each row. so the code is looking at one row at a time.
I have searched but everyone seems to have a different set of needs.
Just use Find and Replace, no need for vba or formulas.
- Select the column containing the data that you need to modify
- Press Ctrlh to open the Find and Replace dialog.
- In the “Find what:” field, type
- In the “Replace with:” field, leave it blank
- Click Replace All
EDIT: If it has to be VBA, this simple macro will accomplish the same thing. Be sure to change the
A to your actual column letter.
Sub tgr() Columns("A").Replace ":*", "" End Sub
EDIT: Upon request I am adding a formula solution. In cell B1 and copied down:
Try this small macro:
Sub colonoscopy() Dim c As String Dim r As Range, I As Long For Each r In ActiveSheet.UsedRange v = r.Value I = InStr(1, v, ":") If I > 0 Then r.Value = Mid(v, 1, I - 1) End If Next r End Sub