Amend Message Box to include Text

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,603
Office Version
  1. 2021
Platform
  1. Windows
I have the following code below



Code:
 Range("f1").Select
 Dim myValue As String
 ActiveCell.FormulaR1C1 = InputBox("Enter the Report month and year")
 Range("F1").NumberFormat = "MMM-YYYY"


I would like to automatically include text in the message box Reporting period : so that when the month and year is entered for eg Jan 2018 it appears as "Reporting period : Jan 2018"


It would be appreciated if someone could kindly amend my code
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
You have some concerns that need addressing first.

Currently, you have no control or validations on what the user can enter into the Input Box. They can enter literally anything they want and it will be accepted.
Secondly, you are trying to apply number formatting to cell F1. That only works for valid number or date entries. It has no effect on string entries.

You are better off using a Calendar Control or Date Picker, which will force them to choose a valid date. Then, you can apply any formatting you like to it, since you know it is a valid date.

Here are a few links that show you how you can do that:
http://www.fontstuff.com/vba/vbatut07.htm
https://www.rondebruin.nl/win/s8/win003.htm
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top