Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default HasFormula() vs. has a "numeric" entry

How can I distinguish if a cell has formula entry (ex: =sum(A1:A25) ) vs. a
simple "numeric entry (ex: 123)?

-would the most efficient way be to check if Right(AnyString, 1) = "="

thanks in advance,
-mark


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default HasFormula() vs. has a "numeric" entry

Try

Dim F As String
Dim S As String

F = ActiveCell.Formula
S = Application.ConvertFormula(F, xlA1, xlR1C1)
If F = S Then
Debug.Print "No cell references"
Else
Debug.Print "cell references"
End If




"mark kubicki" wrote in message
...
How can I distinguish if a cell has formula entry (ex:
=sum(A1:A25) ) vs. a simple "numeric entry (ex: 123)?

-would the most efficient way be to check if Right(AnyString,
1) = "="

thanks in advance,
-mark



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default HasFormula() vs. has a "numeric" entry

what about formulas which use named ranges.
like
=MyRange +1
?


Chip Pearson wrote:
Try

Dim F As String
Dim S As String

F = ActiveCell.Formula
S = Application.ConvertFormula(F, xlA1, xlR1C1)
If F = S Then
Debug.Print "No cell references"
Else
Debug.Print "cell references"
End If




"mark kubicki" wrote in message
...

How can I distinguish if a cell has formula entry (ex:
=sum(A1:A25) ) vs. a simple "numeric entry (ex: 123)?

-would the most efficient way be to check if Right(AnyString,
1) = "="

thanks in advance,
-mark




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default HasFormula() vs. has a "numeric" entry

what about formulas which use named ranges.

Maybe one could include something like this:

Dim nPrecedents As Long

On Error Resume Next 'In case there are none
nPrecedents = ActiveCell.Precedents.Count
If n 0 Then
' There are cell references...
End If

--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"witek" wrote in message
...
what about formulas which use named ranges.
like
=MyRange +1
?


Chip Pearson wrote:
Try

Dim F As String
Dim S As String

F = ActiveCell.Formula
S = Application.ConvertFormula(F, xlA1, xlR1C1)
If F = S Then
Debug.Print "No cell references"
Else
Debug.Print "cell references"
End If




"mark kubicki" wrote in message
...

How can I distinguish if a cell has formula entry (ex: =sum(A1:A25) ) vs.
a simple "numeric entry (ex: 123)?

-would the most efficient way be to check if Right(AnyString, 1) = "="

thanks in advance,
-mark




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default HasFormula() vs. has a "numeric" entry

"Dana DeLouis" wrote in message
...
what about formulas which use named ranges.


Maybe one could include something like this:

Dim nPrecedents As Long

On Error Resume Next 'In case there are none
nPrecedents = ActiveCell.Precedents.Count
If n 0 Then
' There are cell references...
End If

--
HTH. :)
Dana DeLouis



Maybe I missed something, but why not::

if ActiveCell.HasFormula then
'has formula with or without cell references (example for 'without
reference': =10+5)
else
'no formula
end if


Joerg




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default HasFormula() vs. has a "numeric" entry

Dana,

precedents EXCLUDE references to cells other than activesheet.

[sheet1!a1].formula = "=sheet2!a1"
msgbox [sheet1!a1].precedents.count '<No CellsFound

Testing .Formula < .Value appears similar to .HasFormula
surprisingly it is 3x faster.

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Dana DeLouis wrote in

what about formulas which use named ranges.


Maybe one could include something like this:

Dim nPrecedents As Long

On Error Resume Next 'In case there are none
nPrecedents = ActiveCell.Precedents.Count
If n 0 Then
' There are cell references...
End If

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default HasFormula() vs. has a "numeric" entry

Very good point.


"witek" wrote in message
...
what about formulas which use named ranges.
like
=MyRange +1
?


Chip Pearson wrote:
Try

Dim F As String
Dim S As String

F = ActiveCell.Formula
S = Application.ConvertFormula(F, xlA1, xlR1C1)
If F = S Then
Debug.Print "No cell references"
Else
Debug.Print "cell references"
End If




"mark kubicki" wrote in message
...

How can I distinguish if a cell has formula entry (ex:
=sum(A1:A25) ) vs. a simple "numeric entry (ex: 123)?

-would the most efficient way be to check if Right(AnyString,
1) = "="

thanks in advance,
-mark




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
Formula to confirm entry in Col "C" is valid for data in Col "A" VAPCMD Excel Discussion (Misc queries) 2 January 2nd 09 07:58 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
"." on numeric keypad displays "," TOMMIETOM Excel Discussion (Misc queries) 11 March 14th 07 07:34 AM
Excel: Changing "numeric $" to "text $" in a different cell. Heather_CCF Excel Worksheet Functions 1 September 5th 06 06:06 PM
If A3=alpha numeric,"X", if A3=text,"Y", Blank Gary Excel Worksheet Functions 16 August 8th 06 08:27 PM


All times are GMT +1. The time now is 12:25 PM.

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"