Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default If logical statement and a function

Function as follows:

Function ReverseText(myText)
ReverseText = StrReverse(myText)
End Function

Purpose:
to change cell value 35 into cell value 53
this is not a problem.

However, I do not want to exceed 70 in this mirror image.
i.e. 19 becomes 91 which higher than 70 in cell C2

Using:
=If (C270,," ") doesn't work for me, it is not text but a value,
if I add =C2+1 which is 91 + 1 it equals 92
What am I missing?
Which Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default If logical statement and a function

Solution, as I pushed the enter button,

=IF(C270,C2,1)

With Thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default If logical statement and a function

On Sep 25, 8:19*pm, smandula wrote:
Solution, as I pushed the enter button,

=IF(C270,C2,1)

With Thanks


It still doesn't work! I need C2 to register as a value.
If C2 is greater than 70 to register as a blank

=IF(C2<70,C2," "
Cell A1 has the variable ie 35
Cell C2has a formula =ReverseText(A1)
Cell D3 has the above formula =IF(C2<70,C2," ")
Any opinions,
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 806
Default If logical statement and a function

=IF(--C2<70,--C2," ")

Regards,
Bernd
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,059
Default If logical statement and a function

"smandula" wrote:
Cell A1 has the variable ie 35
Cell C2has a formula =ReverseText(A1)
Cell D3 has the above formula =IF(C2<70,C2," ")


At a minimum, try:

=if(--C2<70, C2, "")

Note: I use "", not " ". The latter will cause huge problems for you
later.

The problem you are having is: your ReverseText returns text, not a number.
In a comparison, text is always considered greater than any number. The
form --C2 ensures that the text (presumed to be numeric string) is converted
to a number for the comparison.


Any opinions


Many.

First, why not have this handled in the UDF?

Second, do you really what the UDF to return a number (as long as it meets
the criteria), not text?

Third, why use a UDF in the first place?

If you want to handle this in the UDF, you would write:

Function rt(txt)
x = StrReverse(txt)
If IsNumeric(x) And x < 70 Then rt = x Else rt = ""
End Function

If you want the UDF to return a number instead of text, then write:

Function rt(txt)
x = StrReverse(txt)
If IsNumeric(x) And x < 70 Then rt = --x Else rt = ""
End Function


----- original message -----

"smandula" wrote in message
...
On Sep 25, 8:19 pm, smandula wrote:
Solution, as I pushed the enter button,

=IF(C270,C2,1)

With Thanks


It still doesn't work! I need C2 to register as a value.
If C2 is greater than 70 to register as a blank

=IF(C2<70,C2," "
Cell A1 has the variable ie 35
Cell C2has a formula =ReverseText(A1)
Cell D3 has the above formula =IF(C2<70,C2," ")
Any opinions,



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default If logical statement and a function

On Sep 26, 11:35*am, Bernd P wrote:
=IF(--C2<70,--C2," ")

Regards,
Bernd


Thanks
It works wonderful
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
If Statement with Two Different Logical Test Storm Excel Worksheet Functions 16 December 15th 08 07:22 PM
Logical statement: equivalent of an IN function? The Dude Excel Programming 5 September 12th 08 09:11 AM
Explaination of Logical If Then Statement Mitchell Excel Worksheet Functions 3 July 19th 08 06:15 PM
Logical statement for 'contains' ? Singh Excel Discussion (Misc queries) 1 May 16th 08 03:33 PM
Logical Statement Harley Excel Discussion (Misc queries) 1 January 4th 07 02:37 AM


All times are GMT +1. The time now is 10:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"