Easy inequality if/then statement...

Engineer Joe

Well-known Member
Joined
Jun 10, 2005
Messages
543
For some reason, I can't seem to make this junk work...here's what i'm trying to do. I have to input values (A and B). I'd like make an if statement that operates only if the values of BOTH A and B were input (i.e. not skipped over. The input is done in a textbox in a userform. This if/then statement is also excecuted at commandbutton_click() by the way.) I thought that this would work, but it isn't

Code:
If Not (A ="" or B="") then
blah, blah blah

What is the best way to indicate that A is not equal to nothing or "" or has been defined????

thanksesseseseses
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Damon Ostrander

MrExcel MVP
Joined
Feb 17, 2002
Messages
4,239
Hi Engineer Joe,

It looks like your statement should work properly.

But I'm assuming that A and B are string variables that are set like this:

A = TextBox1.Text

and that the TextBoxes indeed are initialized with a null string. If initialized with any other string (even a single space, as in " "), you should test for that string. If for example, your textboxes were initialized with "(enter dollar value here)" then the test would become:

If Not (A ="(enter dollar value here)" Or B="(enter dollar value here)") Then

or equivalently

If A <> "(enter dollar value here)" Or B <> "(enter dollar value here)" Then


I hope this helps.

Damon
 

Engineer Joe

Well-known Member
Joined
Jun 10, 2005
Messages
543
thanks...you won't believe this...but it's been so long since i've written any vba that i forgot the <> sign.... :unsure:
 

Damon Ostrander

MrExcel MVP
Joined
Feb 17, 2002
Messages
4,239
Hi again Joe,

I think I goofed on that last "or equivalently" code. The OR should have been an AND.

Damon
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,631
Messages
5,832,768
Members
430,166
Latest member
Nige Leeming

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
Top