Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default test first character in cell

can anyone please help with the vba to test the first character in a cell for
either "=" or "$"?

THANKS
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default test first character in cell

schr = left(cell.formula,1)
if schr = "=" or schr = "$" then


Normally, a $ is produced by formatting and is not contained in the cell. In
that case you would do

sChr = left(cell.formula,1)
sChr1 = left(cell.Text,1)
if schr = "=" or schr1 = "$" then

if you want to check if a cell contains a formula

if cell.HasFormula then

Also look at

if vartype(cell) = vbCurrency then

--
Regards,
Tom Ogilvy


"Newbie" wrote:

can anyone please help with the vba to test the first character in a cell for
either "=" or "$"?

THANKS

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default test first character in cell

Top man!! Thanks Tom.

"Tom Ogilvy" wrote:

schr = left(cell.formula,1)
if schr = "=" or schr = "$" then


Normally, a $ is produced by formatting and is not contained in the cell. In
that case you would do

sChr = left(cell.formula,1)
sChr1 = left(cell.Text,1)
if schr = "=" or schr1 = "$" then

if you want to check if a cell contains a formula

if cell.HasFormula then

Also look at

if vartype(cell) = vbCurrency then

--
Regards,
Tom Ogilvy


"Newbie" wrote:

can anyone please help with the vba to test the first character in a cell for
either "=" or "$"?

THANKS

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
How do I test for the first character Kevlar Excel Programming 3 October 2nd 04 01:31 AM
How do I test for the first character Kevlar[_5_] Excel Programming 0 October 1st 04 04:46 PM
How do I test for the first character Kevlar[_4_] Excel Programming 1 October 1st 04 01:02 AM
How do I test for the first character Kevlar[_3_] Excel Programming 1 October 1st 04 12:01 AM
How do I test for the first character Kevlar[_2_] Excel Programming 0 September 30th 04 09:33 PM


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