MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Visual Basic code for a message box when excel opens?

Posted by merlin on January 09, 2001 7:58 AM

Hi all.

When a user opens an excel file, I want to prompt the user to enter a numeric value. Then I want the number they enter into the "message box" to be inserted into an excel formula?

Any ideas or suggestions of how to do this?

Thanks in advance,

Posted by cpod on January 09, 2001 9:18 AM

If you put this code in the on open event for your workbook it will ask for a number and place that number into A1 of the active sheet. You can then use that cell reference in your formula:

Dim sngNum As Double
sngNum = InputBox("Please enter number")
ActiveSheet.[a1] = sngNum