vba - default values in input box?

MikeL

Active Member
Joined
Mar 17, 2002
Messages
488
Office Version
  1. 365
Platform
  1. Windows
Hi,

My basic question is: How do you get a default value to appear in an Input Box?

For example in the code below. The active sheet is renamed "orig", then it is copied, then that sheet needs to be renamed. I would like an input box to pop up with the default word "format" in it and with the ability for the user to overwrite this word.

Any suggestions? (Code is below)
Thanks in advance,
MikeL

Sub Imports_RenameCopyRename()
Dim Default, UserShName
ActiveSheet.Name = "orig"
Sheets("orig").Copy after:=Sheets(1)
Default = "format"
UserShName = InputBox("Please name the new sheet", Default)
Sheets("orig (2)").Name = UserShName
End Sub
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hello,

All you need is to add a second default in the UserShName.

Sub Imports_RenameCopyRename()
Dim Default, UserShName
ActiveSheet.Name = "orig"
Sheets("orig").Copy after:=Sheets(1)
Default = "format"
UserShName = InputBox("Please name the new sheet", Default, Default)
Sheets("orig (2)").Name = UserShName
End Sub

Hope this helps.
 
Upvote 0
Hi , I need one help in input box procedure. I enter path in the input box and want the application to remember last path entered by default next time, User has a option to change the same. If it changes, then in next procedure the last changed path will be shown. How to activate, this feature in VBA.
Thanks & Regards, Pinaki Chatterjee
 
Upvote 0

Forum statistics

Threads
1,215,005
Messages
6,122,661
Members
449,091
Latest member
peppernaut

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