ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Wildcard (https://www.excelbanter.com/excel-programming/299397-wildcard.html)

Kevin

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


Bob Flanagan

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




Nigel[_8_]

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




Don Guillett[_4_]

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





All times are GMT +1. The time now is 01:47 PM.

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