macro to change links????

cmefly

Well-known Member
Joined
May 13, 2003
Messages
683
Hi,

i've got a spreadsheet with a bunch of formulas.

At the moment, it's linked to a file within a folder called c:\profiles.

There are 40 files in this directory.

i need a macro that will change the link in my spreadsheet to each file within the directory...and save the file as "profile_links1", "profile_links2", etc.

any ideas?
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
okay, here are some more details:

here is my macro: my question is located in the starred section ;)

Sub openAllfilesInALocation()

Dim i As Integer
Dim wb As Workbook

Application.ScreenUpdating = False

With Application.FileSearch
.NewSearch
.LookIn = "G:\Profiles"
.SearchSubFolders = False
.Filename = "*.xls"
.Execute

For i = 1 To .FoundFiles.Count
'Open each workbook

Application.DisplayAlerts = False
'*********************
'AT THIS POINT, HOW DO I GET THE NAME OF THE FILE (i) AND ASSIGN IT TO A VARIABLE??????

'*********************************
Set wb = Workbooks.Open(Filename:=.FoundFiles(i))

'Perform the operation on the open workbook
larger_macro

'Save and close the workbook
wb.Save
wb.Close
'On to the next workbook
Next i
End With

Application.ScreenUpdating = True


End Sub
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,822
Members
452,946
Latest member
JoseDavid

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