Partial find and full replace

D

Darin Kramer

Hi there,

Im looking for VB that will look in column U for any instance of "abc"
and when it finds it replace the entire cell contents with nothing.

Thus for eg in cell u2 I have a value abc(if,d2-3,z,y) after the macro
runs I need to have the cell be blank. (ie delete the abc and everything
after it..)

abc is always the first three letters in the cell.

Any ideas..?

Thanks

D
 
B

Bob Phillips

Public Sub ProcessData()
Const TEST_COLUMN As String = "U" '<=== change to suit
Dim i As Long
Dim iLastRow As Long

With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = iLastRow To 1 Step -1
If .Cells(i, TEST_COLUMN).Value Like "abc*" Then
.Cells(i, TEST_COLUMN).Value = ""
End If
Next i

End With

End Sub

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top