Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2007

Tip: Looking for answers? Try searching our database.

More Efficient IF

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David - 28 Sep 2007 10:58 GMT
I posted this 2 hrs ago but it seems to have disappeared, apologies if
it reappears and this is a double post!

I have an IF statement thus:

--

IF Variable = 1 or Variable = 2 or Variable = 7 or Variable = 12 then

--

Is there a more efficient way to do this?

In PICK BASIC for example you have the MATCHES function:

--

If Variable MATCHES (1,2,7,12) Then

--

Is there anything like that in VBA?  Are there any other tips to
improve efficiency/speed in VBA such as putting brackets around
conditionals etc?

Thanks!
Incidental - 28 Sep 2007 12:23 GMT
Hi David

You could use the select case statement

Select Case variable

Case 1, 2, 7, 12

MsgBox "Variable is either 1,2,7,12"

End Select

hope this helps

S
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.