+ Reply to Thread
Results 1 to 8 of 8

Best Practice

  1. #1
    Ardus Petus
    Guest

    Best Practice

    Since I found out yo may write
    [Sheet2!A1:b2].value
    instead of :
    Worksheets("Sheet2").Range("A1:B2").Value

    I would like to know wether this is bad practice or just a performance issue

    TIA

    --
    AP



  2. #2
    Chip Pearson
    Guest

    Re: Best Practice

    Using the [] method is slower than second method. I always use
    the second method, though that is a matter of personal
    preference.


    "Ardus Petus" <[email protected]> wrote in message
    news:%[email protected]...
    > Since I found out yo may write
    > [Sheet2!A1:b2].value
    > instead of :
    > Worksheets("Sheet2").Range("A1:B2").Value
    >
    > I would like to know wether this is bad practice or just a
    > performance issue
    >
    > TIA
    >
    > --
    > AP
    >
    >




  3. #3
    Ardus Petus
    Guest

    Re: Best Practice

    I thought VBA was compiled before execution.
    If true, how come one method is faster than the other?

    TIA

    --
    AP

    "Chip Pearson" <[email protected]> a écrit dans le message de
    news:[email protected]...
    > Using the [] method is slower than second method. I always use
    > the second method, though that is a matter of personal
    > preference.
    >
    >
    > "Ardus Petus" <[email protected]> wrote in message
    > news:%[email protected]...
    > > Since I found out yo may write
    > > [Sheet2!A1:b2].value
    > > instead of :
    > > Worksheets("Sheet2").Range("A1:B2").Value
    > >
    > > I would like to know wether this is bad practice or just a
    > > performance issue
    > >
    > > TIA
    > >
    > > --
    > > AP
    > >
    > >

    >
    >




  4. #4
    Chip Pearson
    Guest

    Re: Best Practice

    The contents of the [] characters are evaluated at run time.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "Ardus Petus" <[email protected]> wrote in message
    news:[email protected]...
    >I thought VBA was compiled before execution.
    > If true, how come one method is faster than the other?
    >
    > TIA
    >
    > --
    > AP
    >
    > "Chip Pearson" <[email protected]> a écrit dans le message de
    > news:[email protected]...
    >> Using the [] method is slower than second method. I always use
    >> the second method, though that is a matter of personal
    >> preference.
    >>
    >>
    >> "Ardus Petus" <[email protected]> wrote in message
    >> news:%[email protected]...
    >> > Since I found out yo may write
    >> > [Sheet2!A1:b2].value
    >> > instead of :
    >> > Worksheets("Sheet2").Range("A1:B2").Value
    >> >
    >> > I would like to know wether this is bad practice or just a
    >> > performance issue
    >> >
    >> > TIA
    >> >
    >> > --
    >> > AP
    >> >
    >> >

    >>
    >>

    >
    >




  5. #5
    Ardus Petus
    Guest

    Re: Best Practice

    Thanks for that definite response!

    --
    AP

    "Chip Pearson" <[email protected]> a écrit dans le message de
    news:%[email protected]...
    > The contents of the [] characters are evaluated at run time.
    >
    >
    > --
    > Cordially,
    > Chip Pearson
    > Microsoft MVP - Excel
    > Pearson Software Consulting, LLC
    > www.cpearson.com
    >
    >
    > "Ardus Petus" <[email protected]> wrote in message
    > news:[email protected]...
    > >I thought VBA was compiled before execution.
    > > If true, how come one method is faster than the other?
    > >
    > > TIA
    > >
    > > --
    > > AP
    > >
    > > "Chip Pearson" <[email protected]> a écrit dans le message de
    > > news:[email protected]...
    > >> Using the [] method is slower than second method. I always use
    > >> the second method, though that is a matter of personal
    > >> preference.
    > >>
    > >>
    > >> "Ardus Petus" <[email protected]> wrote in message
    > >> news:%[email protected]...
    > >> > Since I found out yo may write
    > >> > [Sheet2!A1:b2].value
    > >> > instead of :
    > >> > Worksheets("Sheet2").Range("A1:B2").Value
    > >> >
    > >> > I would like to know wether this is bad practice or just a
    > >> > performance issue
    > >> >
    > >> > TIA
    > >> >
    > >> > --
    > >> > AP
    > >> >
    > >> >
    > >>
    > >>

    > >
    > >

    >
    >




  6. #6
    Don Guillett
    Guest

    Re: Best Practice

    I sometimes use [] because of brevity. Harlan always jumps on me when I do
    it.

    --
    Don Guillett
    SalesAid Software
    [email protected]
    "Chip Pearson" <[email protected]> wrote in message
    news:[email protected]...
    > Using the [] method is slower than second method. I always use the second
    > method, though that is a matter of personal preference.
    >
    >
    > "Ardus Petus" <[email protected]> wrote in message
    > news:%[email protected]...
    >> Since I found out yo may write
    >> [Sheet2!A1:b2].value
    >> instead of :
    >> Worksheets("Sheet2").Range("A1:B2").Value
    >>
    >> I would like to know wether this is bad practice or just a performance
    >> issue
    >>
    >> TIA
    >>
    >> --
    >> AP
    >>
    >>

    >
    >




  7. #7
    Chip Pearson
    Guest

    Re: Best Practice

    > Harlan always jumps on me when I do it.

    Why am I not surprised?


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "Don Guillett" <[email protected]> wrote in message
    news:[email protected]...
    >I sometimes use [] because of brevity. Harlan always jumps on me
    >when I do it.
    >
    > --
    > Don Guillett
    > SalesAid Software
    > [email protected]
    > "Chip Pearson" <[email protected]> wrote in message
    > news:[email protected]...
    >> Using the [] method is slower than second method. I always use
    >> the second method, though that is a matter of personal
    >> preference.
    >>
    >>
    >> "Ardus Petus" <[email protected]> wrote in message
    >> news:%[email protected]...
    >>> Since I found out yo may write
    >>> [Sheet2!A1:b2].value
    >>> instead of :
    >>> Worksheets("Sheet2").Range("A1:B2").Value
    >>>
    >>> I would like to know wether this is bad practice or just a
    >>> performance issue
    >>>
    >>> TIA
    >>>
    >>> --
    >>> AP
    >>>
    >>>

    >>
    >>

    >
    >




  8. #8
    Forum Contributor
    Join Date
    03-03-2005
    Posts
    315
    Following conclusions reached on the use of [], does the same apply to using (for example) [SumA1:A100)] instead of Application.Sum(Range("A1:A100")) or WorkSheetFunction.Sum(Range("A1:A100"))?

    Thanks

    David

+ 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