Conditional Compile in VBA

In Microsoft Excel and Access, when coding in Visual Basic for Applications (VBA) we can use conditional compile to create multiple versions of our compiled code. This is extremely useful when we want to create different versions for different platforms (e.g. 32 bit or 63 bit … or windows vs Mac). We can also use it for compiling debug versions of our code (vs released versions).

This is more an intermediate to advanced level tutorial and there are a few things to watch out for when using conditional compile. I take you through how to create conditional compile constants at both module and project level and then how to use these with the conditional compile keywords to create different compiled versions of your code. I also take you through some of the common “Gotchas”.

The video uses MS Access 2016 (on a 32 bit platform) but the same steps are used for MS Access 2010 and 2013. When using MS Excel (multiple versions) the techniques are again the same … but there are a few less Gotchas to watch out for.

If you enjoyed this short tutorial then please add a comment, start a discussion, “Like”, “Favourite” or “Share” the tutorial and subscribe to my channel.

Click here for more great videos

Click here for more great videos

Thanks for watching!


Leave a Reply

Your email address will not be published. Required fields are marked *