Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default evaluation of a cell with a formula

Hello and Merry Christmas to all
How can I evaluate cells that contain formula? Even if the cell does
not show a result, it is not empty and applying or < is of no use?

My cells contain a formula like: =IF(AND(A424000,A42<9000),I42,"") and I
would like to be able to evaluate and compare them for further action. Like
this (which is not working):
If Not IsEmpty(thisCell) Or Not thisCell.Value = 0# Then
getThisPlanNumberAmount = thisCell.Value
ElseIf thisCell.Value thisCell.Offset(0, 1).Value Then
getThisPlanNumberAmount = thisCell.Offset(0, 1).Value
Else
...................

Thank you


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default evaluation of a cell with a formula

Hi Daniel,

A range has a HasFormula property which you can test like so

If ActiveCell.HasFormula Or Not IsEmpty(ActiveCell.Value) Then
MsgBox "hello"
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Daniel" wrote in message
...
Hello and Merry Christmas to all
How can I evaluate cells that contain formula? Even if the cell does
not show a result, it is not empty and applying or < is of no use?

My cells contain a formula like: =IF(AND(A424000,A42<9000),I42,"") and I
would like to be able to evaluate and compare them for further action.

Like
this (which is not working):
If Not IsEmpty(thisCell) Or Not thisCell.Value = 0# Then
getThisPlanNumberAmount = thisCell.Value
ElseIf thisCell.Value thisCell.Offset(0, 1).Value Then
getThisPlanNumberAmount = thisCell.Offset(0, 1).Value
Else
..................

Thank you




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default evaluation of a cell with a formula

Sometimes if you write your if/thens as separate lines, it'll be easier to break
it down to do what you want:


If Trim(myCell.Value) = "" Then
'either it was outside 4000-9000 or I42 contained ""
Else
If IsNumeric(myCell.Value) Then
If IsNumeric(myCell.Offset(0, 1).Value) Then
'both numeric, so do your comparison
If myCell.Value myCell.Offset(0, 1).Value Then
getThisPlanNumberAmount = myCell.Offset(0, 1).Value
Else
'what happens here
End If
Else
'what happens if myCell is a number, but .offset(0,1) isn't
End If
Else
'what happens if myCell.value is not numeric
End If
End If


There's a lot of "what happens here" lines that you could probably eliminate if
you included And/Or's in your if/then statements.

And one more thing ThisCell is actually a reserved word in some versions of
excel (I think it was added in xl2k--it's in xl2002 for sure).

It refers to the cell that a user defined function was called from.

You may want to change your variable name to something else. I used myCell.




Daniel wrote:

Hello and Merry Christmas to all
How can I evaluate cells that contain formula? Even if the cell does
not show a result, it is not empty and applying or < is of no use?

My cells contain a formula like: =IF(AND(A424000,A42<9000),I42,"") and I
would like to be able to evaluate and compare them for further action. Like
this (which is not working):
If Not IsEmpty(thisCell) Or Not thisCell.Value = 0# Then
getThisPlanNumberAmount = thisCell.Value
ElseIf thisCell.Value thisCell.Offset(0, 1).Value Then
getThisPlanNumberAmount = thisCell.Offset(0, 1).Value
Else
..................

Thank you


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default evaluation of a cell with a formula

Thank you Dave.
________________
"Dave Peterson" a écrit dans le message de
...
Sometimes if you write your if/thens as separate lines, it'll be easier to

break
it down to do what you want:


If Trim(myCell.Value) = "" Then
'either it was outside 4000-9000 or I42 contained ""
Else
If IsNumeric(myCell.Value) Then
If IsNumeric(myCell.Offset(0, 1).Value) Then
'both numeric, so do your comparison
If myCell.Value myCell.Offset(0, 1).Value Then
getThisPlanNumberAmount = myCell.Offset(0, 1).Value
Else
'what happens here
End If
Else
'what happens if myCell is a number, but .offset(0,1) isn't
End If
Else
'what happens if myCell.value is not numeric
End If
End If


There's a lot of "what happens here" lines that you could probably

eliminate if
you included And/Or's in your if/then statements.

And one more thing ThisCell is actually a reserved word in some versions

of
excel (I think it was added in xl2k--it's in xl2002 for sure).

It refers to the cell that a user defined function was called from.

You may want to change your variable name to something else. I used

myCell.




Daniel wrote:

Hello and Merry Christmas to all
How can I evaluate cells that contain formula? Even if the cell

does
not show a result, it is not empty and applying or < is of no use?

My cells contain a formula like: =IF(AND(A424000,A42<9000),I42,"") and

I
would like to be able to evaluate and compare them for further action.

Like
this (which is not working):
If Not IsEmpty(thisCell) Or Not thisCell.Value = 0# Then
getThisPlanNumberAmount = thisCell.Value
ElseIf thisCell.Value thisCell.Offset(0, 1).Value Then
getThisPlanNumberAmount = thisCell.Offset(0, 1).Value
Else
..................

Thank you


--

Dave Peterson



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
Why won't target cell data changes trigger formula evaluation? laura_in_abq Excel Worksheet Functions 3 September 4th 09 09:15 PM
Formula evaluation Edward New Users to Excel 2 March 31st 09 01:31 PM
VLOOKUP FORMULA EVALUATION NEEDED SSJ New Users to Excel 3 March 29th 08 04:15 PM
IF formula - evaluation shows it should work but... Juliet Excel Worksheet Functions 6 January 17th 06 10:39 PM
Blank cell after evaluation JC Excel Discussion (Misc queries) 2 September 15th 05 08:01 PM


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