Help adapting a file path

richanor

Active Member
Joined
Apr 8, 2006
Messages
291
Hi, I am using a macro that somebody gave me to merge several workbooks into one. I have had to adapt a few things including the path where the workbooks are stored (obviously they will be stored in a different place on my PC than they were on his).

In the very top part of the VBA module are these lines:


Option Explicit

Const strFolderPath As String = "C:\Users\Rich\My Documents\Admin\Annual Leave"

Const strSummaryFile As String = "Annual Leave Tracker.xlsm"


I have changed the file path to what I think it is but it keeps throwing up an error. There are a number of files in this folder ("colleage name.xlsx") which are all being merged into "Annual Leave Tracker.xlsm". Is there anyway to just tell the macro to look in the same folder as the "Annual Leave Tracker.xlsm" file?

Thanks

Rich
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
You can get the correct file path like this. Activate an empty sheet then run this macro.

Code:
Sub t()
Range("A1") = Workbooks("Annual Leave Tracker.xlsm").Path
End Sub
 
Upvote 0
Hi, I tried this, but the code above gives me a runtime error 9 - subscript out of range. Any ideas why?
 
Upvote 0

Forum statistics

Threads
1,214,962
Messages
6,122,482
Members
449,088
Latest member
Melvetica

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