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 / March 2006

Tip: Looking for answers? Try searching our database.

best practices question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gary Keramidas - 22 Mar 2006 05:54 GMT
what's the preferred way to do this?

let's say there's a master workbook and child workbooks. the procedure is to
load and copy child data to the master which is already loaded.

when you use the with workbook statement, is it preferred to use:

with workbooks("master")

or

with workbooks("child")

or does it matter?

just wondering

Signature

Gary

Nigel - 22 Mar 2006 08:27 GMT
Hi Gary, better to be "With Master" than "With Child" !!   -
seriously.......

I prefer to use the With statement to encapsulate all the code, so using the
With Master is the way I do it.

With Master
    Child1 actions
    Child2 actions
    etc.
End With

I also as a matter of course assign workbooks and /or relevant worksheets to
object variables to both simplify the code and ease maintenance

Dim wBM As Workbook, wSM As Worksheet
Set wBM = Workbooks("Master")
Set wSM = wBM.Sheets(1)

Hope this helps

Signature

Cheers
Nigel

> what's the preferred way to do this?
>
[quoted text clipped - 12 lines]
>
> just wondering
Gary Keramidas - 22 Mar 2006 08:35 GMT
thanks, just wondering about the with part.

Signature

Gary

> Hi Gary, better to be "With Master" than "With Child" !!   -
> seriously.......
[quoted text clipped - 34 lines]
>>
>> just wondering
Jim Cone - 22 Mar 2006 11:11 GMT
Hi Gary,

The preferred With statement would be the one that eliminates the most dots.  
So "With Workbooks(1).Range("A1").Interior" would be more efficient than
"With Workbooks(2).Range("A1")".
However, you also need to determine the number of times each "With" statement
is referenced.  
For instance, if  a With statement wraps code inside a loop, then that one would
usually be the most efficient.  (assuming that "dots" are actually eliminated)

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware

what's the preferred way to do this?
let's say there's a master workbook and child workbooks. the procedure is to
load and copy child data to the master which is already loaded.

when you use the with workbook statement, is it preferred to use:

with workbooks("master")

or

with workbooks("child")

or does it matter?

just wondering
Gary
 
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.