Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 504
Default Wild Card for partial matches.

I have a column with multiple numbers in them,
example of one cell 0502,0399

I want to be able to find partial matches like just the 0502. right now I
have this..

For Each c In MyRange
If c = "*0502*" Then
MsgBox "yes"
End If
Next c

I'm trying to use the * as a wild card but its looking it up as if I want to
find the * as well as the numbers. Any Ideas?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Wild Card for partial matches.

In regular Excel, the Edit/Find command accepts ? and * as wildcards by
default.

In VBA, look up the LIKE operator.

--

--Andy Smith



"Kevin" wrote:

I have a column with multiple numbers in them,
example of one cell 0502,0399

I want to be able to find partial matches like just the 0502. right now I
have this..

For Each c In MyRange
If c = "*0502*" Then
MsgBox "yes"
End If
Next c

I'm trying to use the * as a wild card but its looking it up as if I want to
find the * as well as the numbers. Any Ideas?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Wild Card for partial matches.

Other possibilities:

- Use Application.WorksheetFunction to use the FIND or SEARCH function

- Use the Find/FindNext/Findprevious method of the Range object

- Use the VBA built-in function Instr

--

--Andy Smith



"Kevin" wrote:

I have a column with multiple numbers in them,
example of one cell 0502,0399

I want to be able to find partial matches like just the 0502. right now I
have this..

For Each c In MyRange
If c = "*0502*" Then
MsgBox "yes"
End If
Next c

I'm trying to use the * as a wild card but its looking it up as if I want to
find the * as well as the numbers. Any Ideas?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Wild Card for partial matches.

sub FindData()
Set rng = Selection.Find(What:="0502", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
End Sub

the LookAt:=xlPart lets if find the substring.

If you want to find all instances, try applying an autofilter using custom
and select Contains and specify 0502 of look in Excel VBA help at the
FindNext method sample code.

--
Regards,
Tom Ogilvy


"Kevin" wrote:

I have a column with multiple numbers in them,
example of one cell 0502,0399

I want to be able to find partial matches like just the 0502. right now I
have this..

For Each c In MyRange
If c = "*0502*" Then
MsgBox "yes"
End If
Next c

I'm trying to use the * as a wild card but its looking it up as if I want to
find the * as well as the numbers. Any Ideas?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 504
Default Wild Card for partial matches.

Like worked for me. thanks a bunch for your help.

"Andy Smith" wrote:

In regular Excel, the Edit/Find command accepts ? and * as wildcards by
default.

In VBA, look up the LIKE operator.

--

--Andy Smith



"Kevin" wrote:

I have a column with multiple numbers in them,
example of one cell 0502,0399

I want to be able to find partial matches like just the 0502. right now I
have this..

For Each c In MyRange
If c = "*0502*" Then
MsgBox "yes"
End If
Next c

I'm trying to use the * as a wild card but its looking it up as if I want to
find the * as well as the numbers. Any Ideas?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wild card quaestion Andrew Mackenzie Excel Discussion (Misc queries) 4 October 28th 09 01:26 PM
Using wild card in IF formula gcukarski Excel Discussion (Misc queries) 3 September 19th 08 12:22 AM
Wild Card!!!??? Sean Excel Programming 3 August 31st 06 06:55 PM
Wild card * Herman Excel Worksheet Functions 0 October 21st 05 01:39 PM
Wild Card Path Chris Sergent Excel Programming 2 September 23rd 04 05:04 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"