Help Identifying the Source Folder of an open file using VBA

JJS

Board Regular
Joined
Jul 8, 2009
Messages
81
Hi All,

I am creating anew macro that will contain some nested IF(AND statements featuring the Vlookup of data from several different workbooks. What I need to be able to do is to identify via VBA, the folder that the open file I am running the macro in is located. This is needed so that I can locate and open the files I need to do the Vlookup against.

Essentially: Workbook A is the main file that I am running the macro on. It needs to know which folder/pathway Workbook A is opened from because the remaining files in the folder (Workbooks B through D) will need to be opened sequentially, have the vlookup run against it and closed. I need to do it this way because there will be different folders (named differently/different pathway) that will need this same macro run.

How do I determine this with VBA and insert it into my code?

Thanks

Jeff
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Try running the macro recorder and opening the file you'll end up referencing. Then look at the recorded code for how it specifies the file.

I'm not a VBA expert, this is just a thought.
 
Upvote 0
SOLVED Re: Help Identifying the Source Folder of an open file using VBA

Hi Warship, on the right track, but it helped me find what I was looking for:

ActiveWorkbook.Path & "\file name.xls"

Does exactly what I need it to, thank you for your help
 
Upvote 0

Forum statistics

Threads
1,203,610
Messages
6,056,296
Members
444,855
Latest member
archadiel

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