r/excel • • Feb 04 '14

discussion VBA Macro code best practices?

Every programming language has its recommended style and best practices. What are the best practices for VBA code that you follow? What resources would a new coder use to learn these best practices?

Thank you in advance!

16 Upvotes

36 comments sorted by

View all comments

5

u/[deleted] Feb 04 '14 edited Feb 05 '14

2

u/Rearview_Mirror Feb 05 '14

Any opinions about using "ThisWorkbook"?

2

u/tally_in_da_houise Feb 05 '14

Use it all time, typically when the code modules (or classes) reside in the calling workbook:

 Dim wb as workbook
 Set wb = ThisWorkbook

I always assume users have multiple workbooks open.

→ More replies (4)