Links don't work in Excel Macro

kyleboyd

New Member
Joined
Feb 22, 2011
Messages
15
I have a macro that (among other things) opens makes some changes and renames a template file. The template file contains a vlookup that references a sheet that is updated (and resaved) every week, so it has to automatically update with the new filename. All of these files are saved on a server.

If I have the vlookup reference using the full server name ie
Code:
=vlookup(example, '[COLOR=black]\\SERVER1\Folder1...[/COLOR]Folder2[COLOR=black]\[Master.xls]Example Sheet'!A1,1)
[/COLOR]

the link doesn't keep up with the resaved filename.

If I have the vlookup reference using the name my computer has set as the file name ie
Code:
=vlookup(example, '[COLOR=black]P:\[/COLOR]Folder2[COLOR=black]\[Master.xls]Example Sheet'!A1,1)
[/COLOR]
the link updates on filename changes but when the macro is run part of the path is left out, rendering the link useless.

The applicable code for the macro is:

Code:
Dim LongPath As String
        LongPath = [URL="file://\\SERVER1\Folder1...Folder2\"]\\SERVER1\Folder1...Folder2[COLOR=black]\[/COLOR][/URL]
 
...
 
Workbooks.Open Filename:=LongPath & "Template X Form.xls"

Hope that makes sense, any help would be appreciated (I'm not exactly a VBA pro). Thanks!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,224,502
Messages
6,179,126
Members
452,890
Latest member
Nikhil Ramesh

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