Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Wildcards in VBA


I'm trying to use a formula that will check the contents of a cell and
color the cell's row accordingly. However, the "keywords" that I'm
looking for won't be the only thing in the cell - they will most likely
be part of a sentence.
With regular formulas, I found that just putting asterisks around the
keywork insde quotation marks works fine. In VBA, though, that doesn't
seem to work.
Any ideas?


--
oodam
------------------------------------------------------------------------
oodam's Profile: http://www.excelforum.com/member.php...o&userid=35513
View this thread: http://www.excelforum.com/showthread...hreadid=553317

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default Wildcards in VBA

You can use the Like keyword for wildcard comparisons:

If strCellValue Like "*" & strTest & "*" Then...

Be aware that it's case-sensitive, so "A" is not Like "a". If
you need case-insentivity use something like

If LCase(strCellValue) Like "*" & LCase(strTest) & "*" Then...

Andrew


oodam wrote:
I'm trying to use a formula that will check the contents of a cell and
color the cell's row accordingly. However, the "keywords" that I'm
looking for won't be the only thing in the cell - they will most likely
be part of a sentence.
With regular formulas, I found that just putting asterisks around the
keywork insde quotation marks works fine. In VBA, though, that doesn't
seem to work.
Any ideas?


--
oodam
------------------------------------------------------------------------
oodam's Profile: http://www.excelforum.com/member.php...o&userid=35513
View this thread: http://www.excelforum.com/showthread...hreadid=553317


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 205
Default Wildcards in VBA

Would the InStr function work for you?

Best regards

John

"oodam" wrote in message
...

I'm trying to use a formula that will check the contents of a cell and
color the cell's row accordingly. However, the "keywords" that I'm
looking for won't be the only thing in the cell - they will most likely
be part of a sentence.
With regular formulas, I found that just putting asterisks around the
keywork insde quotation marks works fine. In VBA, though, that doesn't
seem to work.
Any ideas?


--
oodam
------------------------------------------------------------------------
oodam's Profile:
http://www.excelforum.com/member.php...o&userid=35513
View this thread: http://www.excelforum.com/showthread...hreadid=553317



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Wildcards in VBA

Try using Instr:

If InStr(Cells(1, 1), MyStr) 0 Then MsgBox "Found it"



"oodam" wrote:


I'm trying to use a formula that will check the contents of a cell and
color the cell's row accordingly. However, the "keywords" that I'm
looking for won't be the only thing in the cell - they will most likely
be part of a sentence.
With regular formulas, I found that just putting asterisks around the
keywork insde quotation marks works fine. In VBA, though, that doesn't
seem to work.
Any ideas?


--
oodam
------------------------------------------------------------------------
oodam's Profile: http://www.excelforum.com/member.php...o&userid=35513
View this thread: http://www.excelforum.com/showthread...hreadid=553317


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Wildcards in VBA

You could try using Instr that will return a value 0 if the string is
found. e.g.

If Instr(string1, string2) 0 then
'found
else
'not found
end if

Where string2 is the string to search for in string1. It is case sensitive
as shown
--
Cheers
Nigel



"oodam" wrote in message
...

I'm trying to use a formula that will check the contents of a cell and
color the cell's row accordingly. However, the "keywords" that I'm
looking for won't be the only thing in the cell - they will most likely
be part of a sentence.
With regular formulas, I found that just putting asterisks around the
keywork insde quotation marks works fine. In VBA, though, that doesn't
seem to work.
Any ideas?


--
oodam
------------------------------------------------------------------------
oodam's Profile:
http://www.excelforum.com/member.php...o&userid=35513
View this thread: http://www.excelforum.com/showthread...hreadid=553317





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Wildcards in VBA


Thanks everyone for your help. Much to my surprise, it actually seems
to be working!


--
oodam
------------------------------------------------------------------------
oodam's Profile: http://www.excelforum.com/member.php...o&userid=35513
View this thread: http://www.excelforum.com/showthread...hreadid=553317

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Wildcards in VBA

You probably want to use the InStr function to determine if your substring
exists in the full string. If Instr returns a value then you have found your
substring, otherwise not.

--
HTH...

Jim Thomlinson


"oodam" wrote:


I'm trying to use a formula that will check the contents of a cell and
color the cell's row accordingly. However, the "keywords" that I'm
looking for won't be the only thing in the cell - they will most likely
be part of a sentence.
With regular formulas, I found that just putting asterisks around the
keywork insde quotation marks works fine. In VBA, though, that doesn't
seem to work.
Any ideas?


--
oodam
------------------------------------------------------------------------
oodam's Profile: http://www.excelforum.com/member.php...o&userid=35513
View this thread: http://www.excelforum.com/showthread...hreadid=553317


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
Wildcards in RTD JKC Excel Discussion (Misc queries) 0 February 3rd 06 07:35 PM
Wildcards irresistible007 Excel Worksheet Functions 2 December 20th 05 10:12 AM
Use wildcards furia Excel Discussion (Misc queries) 0 November 16th 05 06:23 PM
wildcards in vba shellshock Excel Discussion (Misc queries) 3 July 21st 05 07:37 PM
Wildcards john Petty Excel Programming 3 August 22nd 03 08:57 PM


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

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

About Us

"It's about Microsoft Excel"