Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default VBA compiled - affects conditional compile?

I've recently discovered conditional compiling in VBA using the
hash-const (#Const). (Many thanks to Jim Thomlinson in this group.)

However, I'm not totally comfortable or familiar with the methods VBA
uses when compiling when a particular module or procedure is called.
I'm trying to determine if conditional compiling would help speed up my
application.

More specifically, I have a long Case statement which chews up time and
makes the screen flicker. I'm trying to determine if converting the
Case statement with a conditionally compiled #If...#ElseIf...#ElseIf
would eliminate unnecessary code to be compiled. However, if the
on-the-fly VBA compiling steps through the conditional code anyways,
there is no advantage.

Is there a resource somewhere which explains how VBA is compiled, what
steps it goes through, and how one may optimize one's code for
compilation time?

Many thanks,
Kevin

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default VBA compiled - affects conditional compile?

Thanks for the help on the VBADecompiler Jim. Excellent resource (I'll
likely use the application provided on the site.)
Returning to the code after the holidays, I see that conditionally
compiling it is not the way to go.

My code, although will be run on different versions of Excel (it's a
multilingual application), is simply to choose between a list of 20
options. Each option is activated on the SelectionChange event of the
Worksheet module since selecting the cell indicates that the option is
selected. The rub is this: these "active" cells are spaced 7 rows apart
(these 7 rows are shown/hidden depending on many things).

So, I initially thought that using conditional compiling could cut down
the 20-long Case statement to something simpler, but I think this is
not the way to go.

Here is the code, in the Worksheet module.


Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
'Calls various forms when the user clicks on cell
'Several cells (20) below A1 will launch a sub, each different
'Each "active" cell is separated by 7 rows of display data which are
hidden in the called sub (subA, subB, etc...)

Dim targetAddress As String
targetAddress = Target.Address

Select Case targetAddress
Case Sheet1.Range("A1").Address
Call SubA
Case Sheet1.Range("A1").Offset(8#).Address
Call SubB
Case Sheet1.Range("A1").Offset(16#).Address
Call SubC
'etc... multiplied by 20, calling subs A through T.

Case Sheet1.Range("A1").Offset(480#).Address
Call SubT

End Select

End Sub


I'm comfortable with this logic and it works well. Just trying to speed
it up.

Regards,

Kevin



On Dec 29 2006, 11:26 am, Jim Thomlinson
wrote:
For a good explanation of the VBA Compiling process give this a read...

http://cpap.com.br/orlando/VBADecompilerMore.asp

That being said you probably don't want to use hash code unless it is to
fundamentally change the way that the program operates (different versions of
XL for instance).

Post the code you are using and perhaps we can help speed it up for you.
--
HTH...

Jim Thomlinson

" wrote:
I've recently discovered conditional compiling in VBA using the
hash-const (#Const). (Many thanks to Jim Thomlinson in this group.)


However, I'm not totally comfortable or familiar with the methods VBA
uses when compiling when a particular module or procedure is called.
I'm trying to determine if conditional compiling would help speed up my
application.


More specifically, I have a long Case statement which chews up time and
makes the screen flicker. I'm trying to determine if converting the
Case statement with a conditionally compiled #If...#ElseIf...#ElseIf
would eliminate unnecessary code to be compiled. However, if the
on-the-fly VBA compiling steps through the conditional code anyways,
there is no advantage.


Is there a resource somewhere which explains how VBA is compiled, what
steps it goes through, and how one may optimize one's code for
compilation time?


Many thanks,
Kevin


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
#N/A Conditional Formatting affects all cells? SMW Excel Discussion (Misc queries) 9 January 8th 10 01:12 AM
Inserting a new column affects conditional formatting tino2009 New Users to Excel 9 June 29th 09 10:18 AM
Conditional formatting affects text as well as values SueG Excel Discussion (Misc queries) 7 March 2nd 09 02:12 PM
conditional compile for LoadPicture? RB Smissaert Excel Programming 2 March 27th 06 04:37 PM
Compiled Excel macros Tomasz Klim Excel Discussion (Misc queries) 4 October 26th 05 11:46 AM


All times are GMT +1. The time now is 12:34 AM.

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"