+ Reply to Thread
Results 1 to 4 of 4

best practices question

  1. #1
    Gary Keramidas
    Guest

    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. #2
    Nigel
    Guest

    Re: 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
    news:%[email protected]...
    > 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. #3
    Gary Keramidas
    Guest

    Re: best practices question

    thanks, just wondering about the with part.


    --


    Gary


    "Nigel" <[email protected]> wrote in message
    news:%[email protected]...
    > 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
    > news:%[email protected]...
    >> 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. #4
    Jim Cone
    Guest

    Re: 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
    news:%[email protected]...
    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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1