Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default More Efficient IF

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!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default More Efficient IF

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
More Efficient IF David Excel Programming 7 September 28th 07 01:51 PM
What is more efficient Brad Excel Discussion (Misc queries) 2 November 20th 06 09:13 PM
more efficient VBA? markx Excel Programming 4 August 7th 06 05:41 PM
More efficient way? Steph[_3_] Excel Programming 6 June 23rd 04 09:34 PM
Which is more efficient? Norm[_5_] Excel Programming 3 April 2nd 04 04:24 PM


All times are GMT +1. The time now is 05:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"