PDA

View Full Version : Benefit of making sheet object rather than directly manipulating sheet



greymalkin
06-24-2008, 02:13 PM
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

grichey
06-24-2008, 02:15 PM
One reason for me is cycling through sheets and portability of code since sheet names always change.

Bob Phillips
06-24-2008, 02:18 PM
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.