#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Wildcard

Hi i have some code where one line is if a cells value = "ABC" then do something. sometimes however it may be ABC inc or ABC corp. The help function wasn't clear on how to search for ABC*. what is the correct syntax pls

Thk

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 340
Default Wildcard

One way to check a cell entry for a string is:

If instr(activecell.value, "ABC") 0 then
'do something
End if

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"kevin" wrote in message
...
Hi i have some code where one line is if a cells value = "ABC" then do

something. sometimes however it may be ABC inc or ABC corp. The help
function wasn't clear on how to search for ABC*. what is the correct syntax
pls.

Thks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Wildcard

If you know the string always starts ABC then you could use

IF LEFT(cell,3) = "ABC" then

or use trim to remove any spurious spaces at the start eg

IF TRIM(LEFT(cell,3)) = "ABC" then

you might like to fix the lower case problem of Abc or ABc etc.....

IF UPPER(TRIM(LEFT(cell,3))) = "ABC" then

Cheers
Nigel


"kevin" wrote in message
...
Hi i have some code where one line is if a cells value = "ABC" then do

something. sometimes however it may be ABC inc or ABC corp. The help
function wasn't clear on how to search for ABC*. what is the correct syntax
pls.

Thks



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Wildcard

You might "like" this. It will pick up abc wherever in the cell.

Sub likeabc()
If UCase(ActiveCell) Like "*ABC*" Then MsgBox "HI"
End Sub

--
Don Guillett
SalesAid Software

"kevin" wrote in message
...
Hi i have some code where one line is if a cells value = "ABC" then do

something. sometimes however it may be ABC inc or ABC corp. The help
function wasn't clear on how to search for ABC*. what is the correct syntax
pls.

Thks



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
Trying to CF using a wildcard toonarme Excel Discussion (Misc queries) 3 July 18th 10 10:52 PM
Wildcard for numbers Huber57 Excel Discussion (Misc queries) 2 May 28th 09 05:56 PM
Using the wildcard with IF DamienO New Users to Excel 5 January 29th 09 01:51 AM
If and wildcard Fish Excel Discussion (Misc queries) 3 October 1st 08 01:33 AM
sum if wildcard Marcel New Users to Excel 1 April 30th 06 11:25 AM


All times are GMT +1. The time now is 04:11 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"