1 min readfrom Microsoft Excel | Help & Support with your Formula, Macro, and VBA problems | A Reddit Community

Accessing data from a separate, closed workbook in a distinct folder tree, but without knowing the workbook name

Our take

Accessing data from a dynamically named CSV file can streamline your automated data collection process. If each result is stored in a unique folder based on a defined structure—like Region, Person, and Department—you can leverage VBA or Power Query to extract data efficiently. By utilizing cell values to specify the folder path, you can programmatically identify and access the latest CSV file within that directory, ensuring that you seamlessly retrieve the necessary data without needing to know the exact filename.

Hi, sorry if the title is confusing, but I am wondering if there's a way to automate accessing data from a .csv workbook when I won't know the workbook's name ahead of time.

I have some automated data collection happening, and it generates workbooks in .csv format, with the timestamp of the data as the filename. Because the filename is a timestamp, I cannot predict it ahead of time, but I do have a unique folder for every result genrated.

Is there a way to use VBA or Power Query along with some of my cell values to provide a folder path and have my sheet automatically extract the desired values from whichever .csv is contained in that folder?

For example, my columns might be:

Region1, Person1, Department1, <Value Array>

And my folder structure would be

.../Region1/Person1/Department1/<timestamp>.csv 

Is there any way to automatically grab one row's worth of data from that CSV given that it's the only file in that folder?

submitted by /u/Nasa1225
[link] [comments]

Read on the original site

Open the publisher's page for the full experience

View original article

Related Articles