PC Review


Reply
Thread Tools Rate Thread

Detecting a single quote from a cells value

 
 
=?Utf-8?B?Sm9obiBLZWl0aA==?=
Guest
Posts: n/a
 
      9th Aug 2007
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.

--
Regards,
John
 
Reply With Quote
 
 
 
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      9th Aug 2007
Sub apostest()
MsgBox (Range("A1").PrefixCharacter)
End Sub

--
Gary''s Student - gsnu200736


"John Keith" wrote:

> 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.
>
> --
> Regards,
> John

 
Reply With Quote
 
=?Utf-8?B?Sm9obiBLZWl0aA==?=
Guest
Posts: n/a
 
      9th Aug 2007
Exactly what I needed, Gary would be proud.

Thanks!

--
Regards,
John


"Gary''s Student" wrote:

> Sub apostest()
> MsgBox (Range("A1").PrefixCharacter)
> End Sub
>
> --
> Gary''s Student - gsnu200736
>
>
> "John Keith" wrote:
>
> > 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.
> >
> > --
> > Regards,
> > John

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      9th Aug 2007
> "Gary''s Student" wrote:
>
>> Sub apostest()
>> MsgBox (Range("A1").PrefixCharacter)
>> End Sub

>
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
If single-quote and double-quote are in text Bob Barnes Microsoft Access 2 25th Nov 2007 09:56 PM
Datagrid on load; replace all double single quote to single quote to display to user Eric Layman Microsoft ASP .NET 3 14th Apr 2007 08:16 AM
Single Quote =?Utf-8?B?S2luamFsaXA=?= Microsoft Excel Discussion 4 6th Apr 2006 12:26 PM
Removing leading single quote (') from cells with Search/Replace =?Utf-8?B?QXJ1bg==?= Microsoft Excel Misc 3 22nd Jan 2006 03:40 AM
Re: Single quote John Spencer (MVP) Microsoft Access Queries 0 17th Jun 2004 12:18 AM


Features
 

Advertising
 

Newsgroups
 


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