Help with inputbox

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
I have code written with an input box that works fine.

myFile = InputBox("Enter a file name")
If myFile = "" Then Exit Sub

I would like to somehow let the user see the available file names to chose from while the input window open. Is this possible? The file names are in the directory c:\estimating\
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi daniels012

You will be better served by using the Excel functions for the FileOpen operations rather then an Inputbox. (if I understand you correctly)

Basic syntax for this is;

Code:
Sub GetOpen()
Dim StrCurDir As String
Dim vFileName As Variant

'// Store current Dir
StrCurDir = CurDir
'// Change to the Dir you need to lookin otherwise your Current!
If Len(Dir("C:\estimating\")) <> 0 Then ChDir ("C:\estimating\")

vFileName = Application.GetOpenFilename("xl Files,*.xls")
If TypeName(vFileName) = "Boolean" Then Exit Sub

Workbooks.Open vFileName
'// Do your thing


'// Restore back to last Dir
ChDir StrCurDir

End Sub
 
Upvote 0

Forum statistics

Threads
1,207,421
Messages
6,078,436
Members
446,337
Latest member
nrijkers

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