How to get rid of string which contain a substring like 'PO BOX'.

D

dukejas

How to get rid of string which contain a substring like 'PO BOX'.

Is that 'Like', it doesn't work.

Thanks!
 
T

Tom Ogilvy

Dim sStr as String
sStr = " the address contains a po box reference"

if instr(1, sStr, "po box", vbTextCompare) then
' it contains the substring "po box"


End if
 
P

pfsardella

Sub NoPO()
Dim rngP As Range

For Each rngP In Selection
If InStr(1, rngP.Value, "PO BOX", vbTextCompare) Then _
rngP.ClearContents
Next rngP

End Sub

Tested using Excel 97SR2 on Windows 98SE,

HTH
Paul
 

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