ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Message box- Assign a file name to a variable, from user input (https://www.excelbanter.com/excel-programming/302143-message-box-assign-file-name-variable-user-input.html)

Sea

Message box- Assign a file name to a variable, from user input
 
Hi,

I need a message box function that I can just call from any module. All I need it to do is ask the user for the filename they are using. Then when user, types in the filename & clicks ok, it assigns to a Global variable. I have the rest of the code out but I am struggling with this part. Doesnt matter about the path as all files are in the same dir.
Any help would be brill Thks Sea


JulieD

Message box- Assign a file name to a variable, from user input
 
Hi Sea

'type this at the top of the module
Public xyz As String

'this is the function
Function getxyz()
xyz = InputBox("What is the filename that you are using?")
End Function


Cheers
JulieD

"Sea" wrote in message
...
Hi,

I need a message box function that I can just call from any module. All I

need it to do is ask the user for the filename they are using. Then when
user, types in the filename & clicks ok, it assigns to a Global variable. I
have the rest of the code out but I am struggling with this part. Doesn't
matter about the path as all files are in the same dir.
Any help would be brill Thks Sea




Tom Ogilvy

Message box- Assign a file name to a variable, from user input
 
fName = Application.GetOpenFileName()

This does not open the file, just provides the user with the file open
dialog to select a file.

It does return the name with the path, but you can strip off the path if you
need to.

--
Regards,
Tom Ogilvy


"Sea" wrote in message
...
Hi,

I need a message box function that I can just call from any module. All I

need it to do is ask the user for the filename they are using. Then when
user, types in the filename & clicks ok, it assigns to a Global variable. I
have the rest of the code out but I am struggling with this part. Doesn't
matter about the path as all files are in the same dir.
Any help would be brill Thks Sea





All times are GMT +1. The time now is 05:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com