Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
True Or False, no matter what... it still displays the false statement
If X = Y then msgbox("They are equal") else msgbox("They are not equal") end if Ok, both X and Y are set to 3. But, the message box "They are no equal" is still shown. I know that both X and Y is set to 3 because when the macro is runnin I but my curser over the variable and it tells me it is equal to 3 -- Message posted from http://www.ExcelForum.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This works for me:
'''''''''''''''''''''''' Dim X As Double, Y As Double X = 3 Y = 3 If X = Y Then MsgBox ("They are equal") Else MsgBox ("They are not equal") End If '''''''''''''''''''''''''''''''''''''' -- steveb (Remove 'NOSPAM' from email address if replying direct) "rocky640 " wrote in message ... True Or False, no matter what... it still displays the false statement If X = Y then msgbox("They are equal") else msgbox("They are not equal") end if Ok, both X and Y are set to 3. But, the message box "They are not equal" is still shown. I know that both X and Y is set to 3 because when the macro is running I but my curser over the variable and it tells me it is equal to 3. --- Message posted from http://www.ExcelForum.com/ |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Rocky,
How are the variables X and Y declared, and are their values computed? It might be the case that the inherent rounding issues with Double or Single variables causes their values to be unequal. For example, X might be 3.00000000000001 and Y might be 3.000000000002. What happens if you write your code like If Abs(X-Y) < 0.0001 Then You might want to post the code that assigns the values to X and Y. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "rocky640 " wrote in message ... True Or False, no matter what... it still displays the false statement If X = Y then msgbox("They are equal") else msgbox("They are not equal") end if Ok, both X and Y are set to 3. But, the message box "They are not equal" is still shown. I know that both X and Y is set to 3 because when the macro is running I but my curser over the variable and it tells me it is equal to 3. --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
TRUE/FALSE STATEMENT | Excel Discussion (Misc queries) | |||
What's the best way to toggle between true and false in Excel? Hiall, My excel work involves a lot of toggling between true and false (booleantypes) ... and it's very repetitive... Is there a way to select a bunch ofcells, and press a key short-cu | Excel Discussion (Misc queries) | |||
TRUE/FALSE function in IF statement | Excel Worksheet Functions | |||
Two TRUE to one FALSE statement | Excel Worksheet Functions | |||
If Statement returns true when false? | Excel Discussion (Misc queries) |