Detecting a single quote from a cells value

J

John Keith

I need to know when the input data contains the prefixed single quote to
force the data to be treated like text.

I am showing SQL table data that contains scripting commands. The presence
of a single tick indicates that this script command is a comment. I want to
process through my script commands and turn the font to green when the script
command being displayed in a cell is a comment.

How do I detect the presence of a prefixed single quote in a cell from VBA?
Left$(cell.value, 1) = "'" is never true because excel strips this
character from the value (although it is still shown in the formula bar)
Neither does the cell.formula show the prefixed single quote (this seems
like it should though)

Is my only option to process the SQL-recordset field to look for the single
quote? I'm hoping that excel's object model has some way to detect the
forcing of a cells value to text.
 
R

Rick Rothstein \(MVP - VB\)

Gary''s Student said:
Exactly what I needed, Gary would be proud.

Well, Gary might be proud except, perhaps, for those extraneous parentheses
around the MsgBox argument.<g>

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top