Search text using wildcards?

  • Thread starter Thread starter ackurv
  • Start date Start date
A

ackurv

I have a macro that performs a loop through a column of text, until th
ActiveCell equals a certain value. Below is the relevant section o
code. How can I test for any cell that has UserID anywhere in it, suc
that it would find text like NWUserId or UserID2?

Do Until ActiveCell = "UserID"
i = i + 1
ActiveCell.Offset(1, 0).Range("A1").Select
Loop

Thank Yo
 
try:
Do Until InStr(ActiveCell.Value, "UserID") <> 0
i = i + 1
ActiveCell.Offset(1, 0).Range("A1").Select
Loop


--
If I've mis-understood the question please tell me.

HTH

ijb

Remove nospam from my e-mail address to talk direct

Not MCSD, MVP, TLA, P&P, PCMCIA, B&Q, etc just trying to help
 
Hi, please try this . . .

Sub FindText()
With ActiveSheet.Range("A1:D10")
Set c = .Find("UserID", LookIn:=xlValues)
If Not c Is Nothing Then firstAddress = c.Address
Do
c.Interior.ColorIndex = 6
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> FirstAddress
End If
End With
End Sub

Regards,

John Mansfield
www.pdbook.com
 

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

Back
Top