VBA Code Library

Free Macro Examples

VBA Code Library

The VBA Code Library is where you’ll find all my stand-alone VBA macros that don’t require a detailed tutorial on my VBA Tutorials Blog.

These macros range from the useful to the quirky, so go ahead and explore! Some may be Excel macros, some may be Word macros and some may be others or universal VBA macros. Each one will have a brief introduction, followed by a self-contained VBA code. I encourage you to adapt them to fit the needs of your particular application!


    • Use VBA to Mute, Unmute, Volume Up and Volume Down


      Did you know you can use VBA to control your computers speakers? This tutorial shows you how to mute and unmute your volume and turn your volume up and down.

    • Convert Decimal Time to Hours Minutes Seconds with VBA


      This VBA function converts decimal times in Excel to words. 10.5 becomes 10 Minutes 30 Seconds. It can convert base times given in hours, minutes or seconds.

    • Use VBA ShellExecute to Open URL in Default Browser


      Use the VBA ShellExecute function to open a URL in the default browser. VBA ShellExecute is a better choice than opening each website in internet explorer.

    • VBA Beep Sound on Error


      The VBA Beep function lets you play a system beep sound whenever you like. VBA Beep usually comes through your speakers so make sure your volume is up.

    • VBA Count Files in Folder


      Use this VBA macro to count the files in a folder. This macro can return the number of total files in a folder or the number of files of a certain type.

    • VBA Loop Through Files in Folder


      Loop through files in a folder with this VBA macro. Use it anytime you need to check each file in a folder or when you want to list the files in a folder.

    • Check if Value is in Array using VBA


      Check if a value is in an array with this VBA function. Use it to look for a string in a string array, an integer in an integer array, and more.

    • VBA to Maximize Window in Left Monitor


      Move your window to the left screen and maximize it with VBA. Placing your window in a consistent position is a must before using mouse control macros.

    • Open Folder using VBA and Show if Already Open


      This macro opens a folder using VBA or shows the open window if the folder is already opened. Pass the macro a string with the folder you want to open.

Discover how this Nuclear Engineer Mastered Excel VBA

And why you should, too


Your time is valuable. It's time to become a VBA expert.