ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Find cells using wildcards (https://www.excelbanter.com/excel-discussion-misc-queries/195035-find-cells-using-wildcards.html)

damorrison

Find cells using wildcards
 
Hello,
I am trying to search for partial strings in a cell,

Sub Button1_Click()
Dim r As Range
Dim c As Range
Dim st As String
Set r = Range("A1", Range("A65536").End(xlUp))
st = InputBox("Enter Partial to Search", "Search By Address")
For Each c In r.Cells
If c = "*" & st & "*" Then '----The problem----
MsgBox c.Address
End If
Next c


End Sub

But do not know how to get the wildcard to work

Bob Phillips[_3_]

Find cells using wildcards
 
If c.Value Like "*" & st & "*" Then

--
__________________________________
HTH

Bob

"damorrison" wrote in message
...
Hello,
I am trying to search for partial strings in a cell,

Sub Button1_Click()
Dim r As Range
Dim c As Range
Dim st As String
Set r = Range("A1", Range("A65536").End(xlUp))
st = InputBox("Enter Partial to Search", "Search By Address")
For Each c In r.Cells
If c = "*" & st & "*" Then '----The problem----
MsgBox c.Address
End If
Next c


End Sub

But do not know how to get the wildcard to work




damorrison

Find cells using wildcards
 
Terrific,
Thanks for that

damorrison

Find cells using wildcards
 
Great, thanks for that


All times are GMT +1. The time now is 09:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com