Excel: If cell begins with #

hankknight
hankknight used Ask the Experts™
on
How can I test if a string of content begins with "#"?

Obviously, my code below does NOT work:

=IF("#HELLO" BEGINS_WITH "#","String begins with #", "String does not begin with #")

Open in new window


I use Office 2010.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
See if the following works:
=IF(LEFT(A1,1)="#", "String begins with #", "String does not begin with #")

Open in new window

This is assuming the cell starts at A1. You can copy the formula down the column if needed.
Top Expert 2008
Commented:
or, if you want VBA instead of formula

IF left(cells(1,1),1)="#" then msgbox("Begins with #") else msgbox("Does not begin with #")

Open in new window


Thomas

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial