Tag Archives: vba Input Box

VBAString Tip 6: Input Box In Excel VBA To Add A Sequence

In this tip will use VBA To add a sequence of months to a worksheet with the input box

First add the following code to a button called “Button1″‘s click event:

In the first image, I am using the VBA inputbox to accept a date entry:


In the following image I am asking the user to confirm their date entry using the VBA msgbox :


If the selection is positive, I am using the DateAdd function, to keep on adding a month according to my loop count.

Also since I am writing to the columns of the worksheet in the first row, which are alpha characters instead of numeric (like the rows), I use “Cells()” which takes the column index instead of the alpha (A-XFD) name like “Range()”,as shown in the following image:


Watch it in action:



Let me know if you have any questions

I consent to having this website store my submitted information so they can respond to my inquiry. See our privacy policy to learn more how we use data.