IF - Then statement not meeting criteria

aberenguel

Board Regular
Joined
Aug 10, 2006
Messages
83
Here's my code
Sub balance_transfer()
' balance_transfer Macro
' Written 09/13/2006 by Anthony Berenguel
'

'
Sheets("OUTPUT TRANSFER").Select

If Range("az235").Select = "FALSE" Then
Call rebalance_1
ElseIf Range("AZ235").Select = "FALSE" Then
Call rebalance_2
ElseIf Range("AZ235").Select = "FALSE" Then
Call rebalance_3
End If

End Sub


I have typed FALSE in cell AZ235 of the output transfer sheet. Therefore excel should call the rebalance_1() macro. But it doesn't. When i step through this code it never calls any of the rebalance macros even though AZ235 equals FALSE.

Please help,
Anthony Berenguel
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Hi Anthony

You are testing the text "FALSE". Maybe AZ235 has the logical value FALSE and not the text "FALSE"?

If AZ235 has the logical value FALSE use

Code:
If Not Range("AZ235").Value Then 
    Call rebalance_1
    Call rebalance_2
    Call rebalance_3
End If
If indeed AZ235 has the text "FALSE", no need for the Select
Code:
If Range("AZ235").Value="FALSE" Then 
    Call rebalance_1
    Call rebalance_2
    Call rebalance_3
End If
Hope this helps
PGC
 
Upvote 0
P. S.

Another solution, that will work in both cases, is to use the text property.
Code:
If Range("AZ235").Text="FALSE" Then 
    Call rebalance_1 
    Call rebalance_2 
    Call rebalance_3 
End If
It works fine but is ambiguous, and so not recommended.
 
Upvote 0
Hi,

you have "Select" which makes it always TRUE
you see ?
Code:
Sub test()
Range("A1") = True
MsgBox Range("A1").Select
Range("A1") = False
MsgBox Range("A1").Select
End Sub

kind regards,
Erik
 
Upvote 0
Thank you, Erik, You are right. If the selection is successful it returns True no matter what is the value of the cell. In my case it's clear that the phrase "The mind is quicker than the hand" does not apply.
 
Upvote 0
thanks everyone!

I have figured it out with all your help. The SELECT part was throwing me off. But thanks again!

Anthony
 
Upvote 0

Forum statistics

Threads
1,214,413
Messages
6,119,372
Members
448,888
Latest member
Arle8907

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top