View Single Post
  #5   Report Post  
Old May 22nd 06, 08:21 PM posted to microsoft.public.excel.misc
Ardus Petus
Posts: n/a
Default Updating Links on Excel

Assuming your monthly data file names end with mm.xls (eg: 06.xls for june),
apply following macro:


Sub NewMonth()
Dim sMonthId As String
Dim rDept As Range
Dim aLinks As Variant
Dim iLink As Integer
Dim sOldLink As String
Dim snewlink As String

sMonthId = Format(Range("A1").Value, "mm")
aLinks = ActiveWorkbook.LinkSources(xlExcelLinks)
If Not IsEmpty(aLinks) Then
For iLink = LBound(aLinks) To UBound(aLinks)
sOldLink = aLinks(iLink)
snewlink = Application.Replace( _
sOldLink, _
InStrRev(sOldLink, ".") - 2, _
Len(sMonthId), _
ActiveWorkbook.ChangeLink _
Name:=sOldLink, _
Next iLink
End If
End Sub
"Update Link Question" <Update Link a
écrit dans le message de news:
I have a spreadsheet that summarizes data from 300+ different workbooks.
Every month a new file is created and we need to update the summary with
new month data. Is there a better way to update the links on the
spreadsheet? Currently, we need to edit links and update links for each
(300+) file name. The only thing that changes in the file names is the