Searching.

  • Thread starter Thread starter Adam
  • Start date Start date
A

Adam

What is the proper notation to use if you want to search
a bunch of cells to see if the contain a value that could
be included anywhere in the cell?

For example, I would like a COUNTA which counts when "W"
is found in any part of the cell. So if the cell said
18389218W928291, it would up the COUNT. If the cell
said "WillyWackingWeirdWonka," it would up the count by
one. What's the easiest way to do this? It appears to
be surprisingly hard to find in Excel documentation.
Thank you!
 
Hi Adam,

I agree, there should be away to do this with a worksheet
function. Perhaps there is, but I couldn't find any way
at first glance. Here is some code that will at least
accomplish what you are looking to acheive:

Sub Macro1()
Dim lonWCount As Long

For Each x In Sheets("Sheet1").Range("A1:A100")
If InStr(1, UCase$(x), "W") > 0 Then
lonWCount = lonWCount + 1
End If
Next x
MsgBox "There are " & lonWCount & " W's in the defined
range."

End Sub
 
Thanks, just what I was looking for Biff! Thanks Danny
for the help also. Microsoft should definately add this
to their documentation.
 
Back
Top