macro to input folder name to get data

fastballfreddy

Board Regular
Joined
Jan 13, 2015
Messages
60
Office Version
  1. 2016
Platform
  1. Windows
I have a code to input date of file for it to open (start of the code below).

I have a main folder called Data that has folders for each previous day's date. I want a code that i can input the folder's name that is in Data to then input the file name of the file in that folder. For example in the Data folder I have a folder named 07-09-2024. I want to input that folder name in a popup box to then grab the file in there.

VBA Code:
 Sub data()
Dim Loc As String
Dim Nme As String
Loc = "D:\Trackers\Data\Review"
Dim Result As Variant
Result = InputBox("Input date MMDDYY", "Date Picker"(
Nme = "Tracking Log " & Nme & ".xlsx"
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Are you aware of the file dialog boxes named msoFileDialogFilePicker or msoFileDialogFolderPicker? Better than an input box IMO. If you will only have 1 file in a folder the first one would be better for you. If multiple files in a folder need to be dealt with, the folder picker might be better suited.
 
Upvote 0
Solution
Thanks! Yes a couple of weeks ago I used it for the first time. After testing a few codes I was able to get what I needed. Thanks for the advice!
 
Upvote 0
Glad I was able to help, and thanks for the recognition.
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,269
Members
452,628
Latest member
dd2

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