Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching for any text within a range

Status
Not open for further replies.

dbuuch

IS-IT--Management
Dec 15, 2003
17
US
The following code searches for the word "attachments" within a range and then display the cell address of that particular cell where it is found. I would like to amend this code so that instead of looking for a particular text it looks for any text at all. Often this whole range would have one or two cells which contain a text string in it and i would like to find these cells using VBA. Can anyone help me out please?

here is the code i have:

Code:
With ActiveSheet.Range("b2:dz500")
    Set c = .Find("Attachments", LookIn:=xlValues)
    If Not c Is Nothing Then
        firstAddress = c.Address
        Do
            MsgBox "Some differences were found in Cell" & c.Address, , "RFSS Status Check"
            Set c = .FindNext(c)
        Loop While Not c Is Nothing And c.Address <> firstAddress
    End If
End With

"To educate a man is to educate an individual; to educate a woman is to educate a nation"
Dr. Aggrey, Ghana.
 
strSearchedText = "any text"
With ActiveSheet.Range("b2:dz500")
Set c = .Find(strSearchedText, LookIn:=xlValues)
...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PH,

Thanks but it didn't work when i tried it. your suggestion seems to be looking for the string "any text" but this isn't what i actually meant. Supposing i didn't know the actual text string, how could i get it to find a cell that contains anything at all (in other words, a cell which is not empty)?

"To educate a man is to educate an individual; to educate a woman is to educate a nation"
Dr. Aggrey, Ghana.
 
Set c = .Find("*", LookIn:=xlValues)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks PHV. You are wonderful. it worked perfectly. You are the man indeed.

thanks,
Daniel


"To educate a man is to educate an individual; to educate a woman is to educate a nation"
Dr. Aggrey, Ghana.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top