Home Excel Powerpoint Word Outlook Error Codes

VBA Useful Codes

Welcome to the World of VBA
Home > VBAUsefulCodes

Inputbox and Msgbox Example

Input box is used to get the inputs from the users while running the macro or in other words at runtime. Msgbox in other words a simple popup box which displays some messages during runtime. Useful when we display some information to users, or when some interaction needs to be performed with the user.

Sub CalcPay()
On Error GoTo HandleError

Dim hours
Dim hourlyPay
Dim payPerWeek

hours = InputBox("Please enter number of hours worked", "Hours Worked")
hourlyPay = InputBox("Please enter hourly pay", "Pay Rate")
payPerWeek = CCur(hours * hourlyPay)
MsgBox "Pay is: " & Format(payPerWeek, "$##,##0.00"), , "Total Pay"
End Sub


Enter your e-mail below and get notified on the latest blog posts.


VBA Outlook KPI Excel Alt+F11 Dashboards Macros Recording Graphs Automation Developer WaterFall Powerpoint Charts Pivot Tables Forecast Charts

Follow Us