Limit of OR operators in one IF Statement

kpark91

Well-known Member
Joined
Jul 15, 2010
Messages
1,582
Hello, I was wondering if there is a maximum number of OR operators I can use in one IF statement.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hello, I was wondering if there is a maximum number of OR operators I can use in one IF statement.

Not that I'm aware of, just a limited number of nested statements (and a limit to how long a formula can be). However, there may be a better, easier, way to handle this IF statement rather than using a bunch of ORs.

Could you please describe what you are needing to do?
 
Upvote 0
Depends how you're trying to write the formula.

If I remember correctly, excel 2003 has a limit of 7 levels of nesting or 30 arguments, excel 2007 / 2010 allows 64 levels or 255 arguments.
 
Upvote 0
OIC. Thank you very much for the explanation.

is there a maximum in VBA?

Could you please describe what you are needing to do?
Well, I have a userform with alot of textboxes where the user can input.
Without the textboxes being filled, the user cannot proceed to the next form.
So, I was meaning to create an if statement to determine if any of the textboxes are empty through OR operators.

But then, I realized I can just loop through the textboxes in one userform and here is the code I have used which have been modified from Excel VBA website code.
Code:
    Dim cCont As Control
 
    For Each cCont In UserMenu.Controls
        If TypeName(cCont) = "TextBox" Then
            With cCont
                If Trim$(.Text) = vbNullString Then
                    MsgBox "All fields must be filled in", vbCritical
                    Exit Sub
                End If
            End With
        End If
    Next cCont
 
    UserMenu.Hide
    Application.Wait 10000
    Load MainMenu
    MainMenu.Show

Is there any errorhandling I must do in this code?
Please and thank you again :)
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,853
Members
452,948
Latest member
UsmanAli786

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