An implementation of Visual Basic that is built into Microsoft products.
Hi @David Hill ,
You can read the cell value directly in VBA.
If the month number is always in a fixed cell, for example A1 on Sheet1, use:
Sub TestMacro()
Dim monthNumber As Long
monthNumber = ThisWorkbook.Worksheets("Sheet1").Range("A1").Value
MsgBox "Month number is " & monthNumber
End Sub
Change "Sheet1" and "A1" to match your actual sheet and cell.
If you want the macro to use the currently selected cell instead, use:
Sub TestMacro()
Dim monthNumber As Long
monthNumber = ActiveCell.Value
MsgBox "Month number is " & monthNumber
End Sub
For a simple month number, .Value is enough. This works in Excel 2024 as well; it does not require Microsoft 365.
You can check these Microsoft VBA references for more information: Range.Value property and Working with the active cell.
If you found my response helpful or informative, I would greatly appreciate it if you could follow this guidance. Thank you.