Find the largest number in a selection
Sub LargetstNumber()
Dim XLnCAD As Double, Sonder As Range
Set Sonder = Selection
XLnCAD = WorksheetFunction.Max(Sonder)
MsgBox XLnCAD
End Sub
Things to remember while using Macros
- By default, the tab for developers is not displayed in excel. If you can’t see the Developer tab, use the quick access toolbar to activate it.
- By default, Macros are disabled in excel. To execute macros, you will need to enable running macros.
- We cannot Undo an action performed using Macro. Make sure that you have a backup of the data before executing the macro.
- To save macros in a workbook, you must save your workbook in a macro-enabled format *.xlsm
- Always fill in the description of the macro when creating one. This will help you understand your own work if you have to revisit it weeks or months later.