Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Which one is faster?
Hello Everybody,
I have Excel 97 Pro on Win98SE. For a certain situation, I have two options: 1. If Else 2. Select Case I just want to ask which one of these is faster? Thank you, -- Syed Zeeshan Haider. http://szh.20m.com/ ----------------------------------- Allah says to Mankind: "Then which of the favours of your Lord will ye deny?" |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Which one is faster?
As a rule of thumb, usually Select Case if there are more than 3 cases.
Regards, Amit "Syed Zeeshan Haider" wrote in message ... Hello Everybody, I have Excel 97 Pro on Win98SE. For a certain situation, I have two options: 1. If Else 2. Select Case I just want to ask which one of these is faster? Thank you, -- Syed Zeeshan Haider. http://szh.20m.com/ ----------------------------------- Allah says to Mankind: "Then which of the favours of your Lord will ye deny?" |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Which one is faster?
There is going to be a readability problem as I already have too many Select
Case in one procedure. If it were in VB (not VBA) I would have preferred "Select Case". If both "Select Case" and "If Else" are same in speed then I will write my code regarding its readability. -- Syed Zeeshan Haider. http://szh.20m.com/ ----------------------------------- Allah says to Mankind: "Then which of the favours of your Lord will ye deny?" "Amit Shanker" wrote in message ... As a rule of thumb, usually Select Case if there are more than 3 cases. Regards, Amit "Syed Zeeshan Haider" wrote in message ... Hello Everybody, I have Excel 97 Pro on Win98SE. For a certain situation, I have two options: 1. If Else 2. Select Case I just want to ask which one of these is faster? Thank you, -- Syed Zeeshan Haider. http://szh.20m.com/ ----------------------------------- Allah says to Mankind: "Then which of the favours of your Lord will ye deny?" |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Which one is faster?
AFAIK, Select Case is slightly faster although the difference could be negligable unless you have many, many logic trees
|
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Which one is faster?
Syed,
Some quick and dirty testing shows that If/Then/Else is about twice as fast as Select Case. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Syed Zeeshan Haider" wrote in message ... Hello Everybody, I have Excel 97 Pro on Win98SE. For a certain situation, I have two options: 1. If Else 2. Select Case I just want to ask which one of these is faster? Thank you, -- Syed Zeeshan Haider. http://szh.20m.com/ ----------------------------------- Allah says to Mankind: "Then which of the favours of your Lord will ye deny?" |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Which one is faster?
But "xlbo" is saying something different. What do you think?
-- Syed Zeeshan Haider. http://szh.20m.com/ ----------------------------------- Allah says to Mankind: "Then which of the favours of your Lord will ye deny?" "Chip Pearson" wrote in message ... Syed, Some quick and dirty testing shows that If/Then/Else is about twice as fast as Select Case. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Syed Zeeshan Haider" wrote in message ... Hello Everybody, I have Excel 97 Pro on Win98SE. For a certain situation, I have two options: 1. If Else 2. Select Case I just want to ask which one of these is faster? Thank you, -- Syed Zeeshan Haider. http://szh.20m.com/ ----------------------------------- Allah says to Mankind: "Then which of the favours of your Lord will ye deny?" |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Which one is faster?
I'd be interested why he came to his conclusion. I do agree,
however, with his statement that the difference is negligible unless you have many, many, logic tree. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Syed Zeeshan Haider" wrote in message ... But "xlbo" is saying something different. What do you think? -- Syed Zeeshan Haider. http://szh.20m.com/ ----------------------------------- Allah says to Mankind: "Then which of the favours of your Lord will ye deny?" "Chip Pearson" wrote in message ... Syed, Some quick and dirty testing shows that If/Then/Else is about twice as fast as Select Case. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Syed Zeeshan Haider" wrote in message ... Hello Everybody, I have Excel 97 Pro on Win98SE. For a certain situation, I have two options: 1. If Else 2. Select Case I just want to ask which one of these is faster? Thank you, -- Syed Zeeshan Haider. http://szh.20m.com/ ----------------------------------- Allah says to Mankind: "Then which of the favours of your Lord will ye deny?" |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Which one is faster?
Syed, you may want to take a look at the following urls for more on this
topic : http://www.ozgrid.com/News/ExcelSele...Dfunctions.htm http://www.ozgrid.com/News/SelectCase2.htm Amit "Chip Pearson" wrote in message ... I'd be interested why he came to his conclusion. I do agree, however, with his statement that the difference is negligible unless you have many, many, logic tree. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Syed Zeeshan Haider" wrote in message ... But "xlbo" is saying something different. What do you think? -- Syed Zeeshan Haider. http://szh.20m.com/ ----------------------------------- Allah says to Mankind: "Then which of the favours of your Lord will ye deny?" "Chip Pearson" wrote in message ... Syed, Some quick and dirty testing shows that If/Then/Else is about twice as fast as Select Case. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Syed Zeeshan Haider" wrote in message ... Hello Everybody, I have Excel 97 Pro on Win98SE. For a certain situation, I have two options: 1. If Else 2. Select Case I just want to ask which one of these is faster? Thank you, -- Syed Zeeshan Haider. http://szh.20m.com/ ----------------------------------- Allah says to Mankind: "Then which of the favours of your Lord will ye deny?" |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Which one is faster?
I didn't see anything in those primer articles that had to do with the speed
of Select case vice using If then Else. -- Regards, Tom Ogilvy "Amit Shanker" wrote in message ... Syed, you may want to take a look at the following urls for more on this topic : http://www.ozgrid.com/News/ExcelSele...Dfunctions.htm http://www.ozgrid.com/News/SelectCase2.htm Amit "Chip Pearson" wrote in message ... I'd be interested why he came to his conclusion. I do agree, however, with his statement that the difference is negligible unless you have many, many, logic tree. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Syed Zeeshan Haider" wrote in message ... But "xlbo" is saying something different. What do you think? -- Syed Zeeshan Haider. http://szh.20m.com/ ----------------------------------- Allah says to Mankind: "Then which of the favours of your Lord will ye deny?" "Chip Pearson" wrote in message ... Syed, Some quick and dirty testing shows that If/Then/Else is about twice as fast as Select Case. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Syed Zeeshan Haider" wrote in message ... Hello Everybody, I have Excel 97 Pro on Win98SE. For a certain situation, I have two options: 1. If Else 2. Select Case I just want to ask which one of these is faster? Thank you, -- Syed Zeeshan Haider. http://szh.20m.com/ ----------------------------------- Allah says to Mankind: "Then which of the favours of your Lord will ye deny?" |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Which one is faster?
There is no discussion of performance in those articles.
-- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Amit Shanker" wrote in message ... Syed, you may want to take a look at the following urls for topic : http://www.ozgrid.com/News/ExcelSele...Dfunctions.htm http://www.ozgrid.com/News/SelectCase2.htm Amit "Chip Pearson" wrote in message ... I'd be interested why he came to his conclusion. I do agree, however, with his statement that the difference is negligible unless you have many, many, logic tree. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Syed Zeeshan Haider" wrote in message ... But "xlbo" is saying something different. What do you think? -- Syed Zeeshan Haider. http://szh.20m.com/ ----------------------------------- Allah says to Mankind: "Then which of the favours of your Lord will ye deny?" "Chip Pearson" wrote in message ... Syed, Some quick and dirty testing shows that If/Then/Else is about twice as fast as Select Case. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Syed Zeeshan Haider" wrote in message ... Hello Everybody, I have Excel 97 Pro on Win98SE. For a certain situation, I have two options: 1. If Else 2. Select Case I just want to ask which one of these is faster? Thank you, -- Syed Zeeshan Haider. http://szh.20m.com/ ----------------------------------- Allah says to Mankind: "Then which of the favours of your Lord will ye deny?" |
#11
Posted to microsoft.public.excel.programming
|
|||
|
|||
Which one is faster?
Hi Syed,
But "xlbo" is saying something different. What do you think? It all depends on what you include in the comparisons. Take the seemingly equivalent code: Select Case a Case b Case c Case d End Select If a = b Then ElseIf a = c Then ElseIf a = d Then End If If a is a constant or a simple variable, a simple timing test shows that the If..ElseIf is faster. However, if a is an expression to evaluate, that evaluation is done once in the Select Case and multiple times in the If..ElseIf, which will probably negate the difference in speed between the two constructs. Personally, I find Select case easier to read and prefer it, but as ever with performance tuning, the only solution is to test it using your own code and data. Regards Stephen Bullen Microsoft MVP - Excel www.BMSLtd.co.uk |
#12
Posted to microsoft.public.excel.programming
|
|||
|
|||
Which one is faster?
Hi Syed,
But "xlbo" is saying something different. What do you think? It all depends on what you include in the comparisons. Take the seemingly equivalent code: Select Case a Case b Case c Case d End Select If a = b Then ElseIf a = c Then ElseIf a = d Then End If If a is a constant or a simple variable, a simple timing test shows that the If..ElseIf is faster. However, if a is an expression to evaluate, that evaluation is done once in the Select Case and multiple times in the If..ElseIf, which will probably negate the difference in speed between the two constructs. Personally, I find Select case easier to read and prefer it, but as ever with performance tuning, the only solution is to test it using your own code and data. Regards Stephen Bullen Microsoft MVP - Excel www.BMSLtd.co.uk |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I print faster? | Excel Discussion (Misc queries) | |||
Can be here some changes for a faster speed ? | Excel Worksheet Functions | |||
can this be done faster? | Excel Discussion (Misc queries) | |||
Can faster CPU+larger/faster RAM significantly speed up recalulati | Excel Discussion (Misc queries) | |||
better/faster way than sum products? | Excel Worksheet Functions |