I have written previously about User Defined Types, where I showed what I feel is a good, legitimate use of UDTs, namely the saving of application settings at the start of my procedures, then re-instating them at the end. I have since extended that technique to make it more generic, as follows Public Type ApplicationValues AppEnableEvents As Boolean AppScreenUpdating As Boolean AppDisplayAlerts As Boolean AppCalculation As XlCalculation End Type Public Function DoSomeStuff() Dim myAppSettings As ApplicationValues Call AppSettings(State:=”Set”, _ AppType:=mpAppSettings, _ AppEvents:=True, _ AppScreen:=False, _ AppAlerts:=False, _ AppCalc:=-1) On Error GoTo func_error … main code func_exit: Call … Continue reading Typing May Be Good For You
So many times you see someone asking about whether they should split their VBA code into many modules, if so, how should they structure it? We probably know that there is a limit to the amount of code that a VBA code module can handle. The code module is essentially an in-file text file (if exported it can be viewed with a simple text eitor), and can accomodate a size of approx 64k bytes. As such, the answer to that previous question should always be an emphatic yes. But it also should be yes from a code maintainability persepctive, even … Continue reading Too many Modules Spoil the VBA Project?