Find Macro
Find Macro
(OP)
Data Sheet contains generic model designations:
AA-A
AA-B
AA-D
AA-BA
How do I get a macro to find "AA-B" and "AA-BA" from my data sheet using values like AA-B1 or AA-BA2C?
=====
Model = "AA-B1"
I tried:
With ActiveSheet.Range("A3:A500")
Set c = .Find(Model, LookIn:=xlValues, LookAt:=xlPart)
and:
For Each c In [A3:A500]
If c Like Model Then
AA-A
AA-B
AA-D
AA-BA
How do I get a macro to find "AA-B" and "AA-BA" from my data sheet using values like AA-B1 or AA-BA2C?
=====
Model = "AA-B1"
I tried:
With ActiveSheet.Range("A3:A500")
Set c = .Find(Model, LookIn:=xlValues, LookAt:=xlPart)
and:
For Each c In [A3:A500]
If c Like Model Then





RE: Find Macro
InStr([start, ]your cell, "AA-B",compare]) and
InStr([start, ]your cell, "AA-BA",compare])
m777182
RE: Find Macro
I'll give that a try. I'll need to use a variable for "AA-B" because I have several hundred. Will InStr work that way. I may just can the macro and use vLookup.
Roger
RE: Find Macro
On a sheet with a Command button, a ListBox and a TextBox, add this code to the Sheet code page:
CODE
ListBox1.Clear
For a = 1 To 16
If Cells(a, 1).Value Like TextBox1.Text Then ListBox1.AddItem (Cells(a, 1).Value)
Next a
End Sub
To find B in position 2, use ?B*
To find all '2 character only' strings use ??
? replaces a single character and * replaces all remaining characters
Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376 before posting
UK steam enthusiasts: www.essexsteam.co.uk
RE: Find Macro
RE: Find Macro
will the built-in autofilter feature/capability suffice for your needs?
good luck!
-pmover
RE: Find Macro
Thanks for the suggestion though.
RE: Find Macro
If Cells(a, 1).Value Like TextBox1.Text Then ListBox1.AddItem (Cells(a, 1).Value) & vbTab & (Cells(a, 2).Value)
Of course you can return the items to stuff other than a listbox!
Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376 before posting
UK steam enthusiasts: www.essexsteam.co.uk