Hello!
In the follow code I'm getting the error:
Run-time error '1004':
Method 'ChangeLink' of object '_Workbook' failed.
The code of Sub:
I use it in the main Sub as this:
Please, help me to figure out where I am doing wrong?
In the follow code I'm getting the error:
Run-time error '1004':
Method 'ChangeLink' of object '_Workbook' failed.
The code of Sub:
Code:
Sub UpdateLink(wnd As Workbook, rng As Range, Newlink As String)
Dim s As String
If rng.HasFormula And _
InStr(1, LCase(rng.Formula), "!") <> 0 _
Then
s = rng.Formula
wnd.ChangeLink Name:=s, Newname:=Newlink, Type:=xlExcelLinks
Else
rng.FormulaR1C1 = Newlink
End If
End Sub
I use it in the main Sub as this:
Code:
For i = 1 To NumTask
SubTask = "M" & i
Prm = "Run_Prm_M" & i
If i = 2 Then
Frm = "='" & thisws.Range("M0_Folder") & ThisWorkbook.Name & "'!Run_Param_" & SubTask
Else
Frm = "='" & thisws.Range("M0_Folder") & ThisWorkbook.Name & "'!Run_Param_" & SubTask & "/100"
End If
Call UpdateLink(srcwb, srcws.Range(Prm), Frm)
Next i
Please, help me to figure out where I am doing wrong?