Pass this VBA function a range of cells and a number that you want to find a number closest to and it will return the value in the range closest to your target.
Generate random numbers in VBA by using the Rnd function. Make the numbers even more random by adding the VBA Randomize statement.
We've combined each of our comprehensive wellsrPRO VBA training reference guides into a single bundle with over 180 tips and macros covering the 100 most important topics in VBA.
Tell me more
The VBA Round function behaves differently than the Excel Worksheet ROUND function. This tutorial explains the differences between the two rounding functions.
Learn how you can align the text in each column of your UserForm ListBox differently by using the class module I introduce in this tutorial.
Find out how to assign a macro to a shape in Excel so you can quickly run your macro by simply clicking the shape in your spreadsheet.
Use Excel to record your mouse clicks and cursor movements and convert them directly into VBA macros so you can easily automate complex tasks, like copying data from a website.
Learn how to show a system tray notification balloon in your start menu the moment your macro is done by following this awesome Excel VBA tutorial.
Use the VBA Dir function to check if a file exists. The VBA Dir function returns the name of a valid file, so you can use it to test whether a file exists.
Return the value in one range based on the relative position of a value in another range without the index, match or offset functions by using this Excel UDF.
This tutorial shows you how to hide the border on your UserForm using VBA. A UserForm without a title bar and X button are far cleaner than normal UserForms.
Instead of using Data Validation, you can use VBA to allow only numbers in a cell or a range in Excel. Read on to learn how to restrict non-numeric characters.
subscribe via RSS
Grab a copy of our VBA Developer's Kit and start writing better macros in half the time.