Function and Sub in Excel VBA
The difference between a function and a sub in Excel VBA is that a function can return a value while a sub cannot. Functions and subs become very useful as program size increases.
Learn how to use Excel like a pro with easy-to-follow tutorials and tips — spreadsheets, charts, pivot tables, and macros.
The difference between a function and a sub in Excel VBA is that a function can return a value while a sub cannot. Functions and subs become very useful as program size increases.
Use the IFERROR function in Excel to return an alternative result such as text when a formula evaluates to an error. For example Excel returns the #DIV/0! error ...
Use the If Then statement in Excel VBA to execute code lines if a specific condition is met.
To create a heat map in Excel simply use conditional formatting. A heat map is a graphical representation of data where individual values are represented as colors.
The VLOOKUP function is one of the most popular functions in Excel. This page contains many easy to follow VLOOKUP examples.
To return the sheet name in a cell use CELL FIND and MID in Excel. There's no built-in function in Excel that can get the sheet name.
Excel offers three different workbook views: Normal Page Layout and Page Break Preview.
With just a few lines of code we can easily loop through controls on an Excel VBA Userform.
Learn how to check the spelling of text in Excel add words to your custom dictionary (or AutoCorrect list) and learn how to change spell checking options.
Insert a comment in Excel to start a conversation or to give feedback about the content of a cell. Old style comments are still available and are now called notes.
Use LAMBDA and the Name Manager in Excel to create your own Excel function. You can use this custom function like any other Excel function!
This example illustrates two functions to chop off decimals in Excel. INT and TRUNC.
Excel has two very useful functions when it comes to generating random numbers. The RAND function generates a random decimal number between 0 and 1.
This example teaches you how to swap two values in Excel VBA. You will often need this structure in more complicated programs as we will see later.
This example teaches you how to sort data by color in Excel.
The mother of all objects is Excel itself. We call it the Application object. The application object gives access to a lot of Excel related options.
Mark a workbook as final in Excel to indicate that this is the final version of your workbook. Only use this feature to discourage editing. Users can still edit the workbook.
An easy formula that returns the day of the year for a given date in Excel. There's no built-in function in Excel that can do this.
Sometimes you want to retain the value of a variable in Excel VBA when a procedure ends. You can achieve this by using the Static keyword.
Data bars in Excel make it very easy to visualize values in a range of cells. A longer bar represents a higher value.
You can find most charts on the same worksheet as the source data (embedded charts). However you can also move a chart to a separate sheet that only contains a chart (chart sheet).
Use the 'Paste Special Skip Blanks' option and Excel will not overwrite existing values with blanks. To create a formula that skips blank cells use IF and ISBLANK.
A dynamic named range in Excel expands automatically when you add a value to the range.
Enable macros in Excel when the message bar appears. Change your macro security settings in the Trust Center. To create macros turn on the Developer tab.