Select Case syntax

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,926
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
What is the difference between this:

Code:
Select Case MyCondition

    Case vbNullstring

    Case Else

End Select

and this:

Code:
Select Case MyCondition

    Case Is = vbNullstring

    Case Else

End Select

I seem to remember there IS a difference, if you were testing for a value or something along those lines.

Thanks
 
Last edited:

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
select statement need all little change with Nulls,

Code:
Select Case true
   Case IsNull(MyCondition)
   Case Else
End Select
 
Upvote 0
I believe the two are equivalent. As you know, the "Is" keyword is used with comparison operators, such as less than (<), less than or equal to (<=), greater than (>), greater than or equal to (>=), not equal to (<>), and equal (=) . In the case of equal, though, "Is =" isn't necessary. You can simply use "Case vbNullstring". You'll see that if you assign MyCondition an empty string ("") or vbNullstring, both statements will be evaluated as True.
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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