Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default best practices question

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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default best practices question

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


--
Cheers
Nigel



"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
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





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default best practices question

thanks, just wondering about the with part.


--


Gary


"Nigel" wrote in message
...
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


--
Cheers
Nigel



"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
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







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default best practices question

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


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
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



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
Best Practices (Counter) Dax Arroway Excel Discussion (Misc queries) 3 December 18th 08 01:47 AM
Comparing Spreadsheets - best practices James Excel Discussion (Misc queries) 1 March 15th 08 02:01 PM
Best practices for pulling data from a network Excel file (mult users) KR Excel Programming 0 March 7th 06 07:40 PM
Design Best Practices: Form Control Code in Worksheet or Module Bing Excel Programming 2 December 23rd 04 02:31 PM
Best practices pivot using SQL-sourced table? Howard J Excel Programming 0 November 3rd 03 08:50 PM


All times are GMT +1. The time now is 06:43 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"