Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Im looking for a code that will do the
Edit LinkUpdate source and change the sheet names of the external files to the correct names in my formulas? |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Try using the =HYPERLINK() function
If this post helps click Yes --------------- Jacob Skaria "Lost" wrote: Im looking for a code that will do the Edit LinkUpdate source and change the sheet names of the external files to the correct names in my formulas? |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Do your external files have only one sheet ?
Daniel Im looking for a code that will do the Edit LinkUpdate source and change the sheet names of the external files to the correct names in my formulas? |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
yes i have 7 external files, 6 of them have 6 sheets and the last one has 14.
"Daniel.C" wrote: Do your external files have only one sheet ? Daniel Im looking for a code that will do the Edit LinkUpdate source and change the sheet names of the external files to the correct names in my formulas? |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Try :
Sub test() Dim lk, mySheet As String, sh As Worksheet Dim f As String, p As String, Addr As String Dim oldTxt As String, newTxt As String, c As Range Dim Pos As Integer, ResAdr As String Application.ScreenUpdating = False For Each lk In ActiveWorkbook.LinkSources(xlExcelLinks) f = Dir(lk) Workbooks.Open lk mySheet = Sheets(1).Name rep = InputBox("If needed, change the sheet name for workbook " & f, , mySheet) If rep < "" Then mySheet = rep p = ActiveWorkbook.Path ActiveWorkbook.Close False oldTxt = "='" & p & "\[" & f & "]" For Each sh In Sheets Set c = sh.Cells.Find(oldTxt, , xlFormulas) If Not c Is Nothing Then Do ResAdr = c.Address Pos = InStr(1, c.Formula, "!") Adr = Right(c.Formula, Len(c.Formula) - Pos) newTxt = "='" & p & "\[" & f & "]" & mySheet & "'!" & Adr c.Formula = newTxt Set c = sh.Cells.FindNext(c) Loop While c < "" And c.Address < ResAdr End If Next sh Next lk Application.ScreenUpdating = True End Sub HTH Daniel yes i have 7 external files, 6 of them have 6 sheets and the last one has 14. "Daniel.C" wrote: Do your external files have only one sheet ? Daniel Im looking for a code that will do the Edit LinkUpdate source and change the sheet names of the external files to the correct names in my formulas? |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Sorry kinda new to this VB thing -
Where in the VB editor do i put this and do I have to change anything? "Daniel.C" wrote: Try : Sub test() Dim lk, mySheet As String, sh As Worksheet Dim f As String, p As String, Addr As String Dim oldTxt As String, newTxt As String, c As Range Dim Pos As Integer, ResAdr As String Application.ScreenUpdating = False For Each lk In ActiveWorkbook.LinkSources(xlExcelLinks) f = Dir(lk) Workbooks.Open lk mySheet = Sheets(1).Name rep = InputBox("If needed, change the sheet name for workbook " & f, , mySheet) If rep < "" Then mySheet = rep p = ActiveWorkbook.Path ActiveWorkbook.Close False oldTxt = "='" & p & "\[" & f & "]" For Each sh In Sheets Set c = sh.Cells.Find(oldTxt, , xlFormulas) If Not c Is Nothing Then Do ResAdr = c.Address Pos = InStr(1, c.Formula, "!") Adr = Right(c.Formula, Len(c.Formula) - Pos) newTxt = "='" & p & "\[" & f & "]" & mySheet & "'!" & Adr c.Formula = newTxt Set c = sh.Cells.FindNext(c) Loop While c < "" And c.Address < ResAdr End If Next sh Next lk Application.ScreenUpdating = True End Sub HTH Daniel yes i have 7 external files, 6 of them have 6 sheets and the last one has 14. "Daniel.C" wrote: Do your external files have only one sheet ? Daniel Im looking for a code that will do the Edit LinkUpdate source and change the sheet names of the external files to the correct names in my formulas? |
#7
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Sorry kinda new to this VB thing -
Where in the VB editor do i put this and do I have to change anything? You'll have to put it in a standard module of the workbook you need to change the links. In the VBE window, right click in the project correspponding to the workbook, click "Insert" and "module". Then, paste the code on the right of the window. Here is a sample file : http://www.filedropper.com/lost Daniel |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Update Source data in a formula | Excel Worksheet Functions | |||
Why will links not update unless source is open? | Excel Discussion (Misc queries) | |||
Change Source / Update Now buttons not available | Links and Linking in Excel | |||
Update Chart Source (w/macro?) | Excel Worksheet Functions | |||
Update fails. Source not found. | Links and Linking in Excel |