Consulting

Results 1 to 3 of 3

Thread: Benefit of making sheet object rather than directly manipulating sheet

  1. #1

    Benefit of making sheet object rather than directly manipulating sheet

    Hello,

    This is just for my own personal learning. Becaus of my lack of experience in VBA and doing things how I initially learned to do them, I've always just manipulated sheets by going to the sheet and crawling through the cells using offset.

    I notice many of the suggestions on this site (other than my own of course) involve creating sheet objects then performing the data manipulation on that object

    Is this done to increase performance, make the code easier to write, or both? I'm just trying to learn more about VBA so I don't always give people the dirty solution to a problem

  2. #2
    VBAX Mentor
    Joined
    Oct 2007
    Posts
    372
    Location
    One reason for me is cycling through sheets and portability of code since sheet names always change.

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Because you can then stop worrying about whether the activesheet is the right sheet, and it is more efficient as you have told VBA exactly which sheet you are referring to, it does have to go and fetch the information, its in memory.

    And, it helps documenting, you can use names like shMaster, shSummary, shInput,a nd know what something about the sheet.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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