What’s the Difference between INT, TRUNC, and ROUND?

The Excel functions INT, TRUNC, and ROUND all do similar things. What’s the difference? INT Truncates a number down to the nearest integer TRUNC Truncates a number towards zero.  It truncates to an integer or an optional number of decimals. INT and TRUNC produce the same result with positive numbers.  They differ in the way…

The Cowboy Function ROUNDUP, and its Pals ROUNDDOWN, ROUND and MROUND

Nothing to do with Cowboys really (nor Monsanto either), just couldn’t resist the pun. ROUND(number, num_digits) rounds to the nearest digit (up or down as required)ROUNDUP(number, num_digits) always rounds up* to the nearest digitROUNDDOWN(number, num_digits) always rounds down* to the nearest digit The functions take the following arguments: Number (required): Any real number that you…

|

Should I use a VBA Macro Function or Call a Worksheet Function?

If the function you want to use exists in Excel VBA, use that.  It will be faster and cleaner, and work in all Microsoft Office programs, not only in Excel.  Here is a full list of Excel VBA Functions.  If the function you want is not there, but exists in the Worksheet, you may be…

| |

How to Use a Worksheet Function in a Macro: Proper Case Names

In some cases, VBA does not have a specific function, but the Excel Worksheet does. This Excel Visual Basic (VBA) code example demonstrates: How to call that Worksheet Function from a Macro. In this particular example, how to call the Worksheet Function =PROPER() from VBA. The function to downcase parts of surnames that normally appear…

|

Flowchart: Which Excel LOOKUP Function Should I Use?

When you want to look up data in Excel, you can choose from various functions: LOOKUP (in two forms), VLOOKUP, HLOOKUP, and the combination of INDEX(MATCH). Which should you use?  Here’s a flowchart to help guide you: The first and most important question is, “do you want an exact match or an approximate match?” If…

Use INDEX(MATCH) instead of an Excel LOOKUP Function

For some lookups, the INDEX and MATCH functions used together may be the solution.  Together, they are more robust and versatile than VLOOKUP, HLOOKUP, and LOOKUP. MATCH returns the position of the matched item in a one-dimensional list. It can do an exact or approximate match.  MATCH(lookup_value, lookup_array, 0) does an exact match. INDEX returns…