0

I've got a newbie questions, is it better to have all the sub and function code in a single, big, module or should it be split for example one module per sub/function ?

Thanks in advance!

CCM
  • 136
  • 2
  • 4
  • 17
  • Depends on what you want to do. There is top down, bottom up, and object orientated. – Bender Bending Aug 01 '17 at 13:33
  • I tend to split different projects into many different modules, but I've gotten in a good habit of naming all my modules (ex. modUpdateYearFiles, etc.) I would definitely suggest you do the same. It's no fun milling through 30+ modules. – dwirony Aug 01 '17 at 13:39
  • Related: https://stackoverflow.com/questions/3255478/put-excel-vba-code-in-module-or-sheet – Jean-François Corbett Aug 01 '17 at 13:45

2 Answers2

1

VBA is not like newer languages where classes are the main thing. That makes it fairly free to spread the code in modules as you see fit. If you do use class modules, then you must think object oriented, but otherwise not much to worry about.
Having that said,
I've seen many big projects with less than a dozen modules.

Sam
  • 5,424
  • 1
  • 18
  • 33
-1

For VBA, it doesn't matter. For you, it's best when organized in a way that let you find quickly what you are looking for. Keeping structure tidy is the only purpose of modules.

Egan Wolf
  • 3,533
  • 1
  • 14
  • 29