PC Review


Reply
Thread Tools Rate Thread

ChangeLink with Worksheet Named Ranges as Arguments

 
 
=?Utf-8?B?UGhpbGlwIEogU21pdGg=?=
Guest
Posts: n/a
 
      23rd Apr 2007
I saw on an earlier post that the way to update links is to use the
ChangeLink method
I used VBA help and derived the following.

Sub MSLinks2()
' This Works
ActiveWorkbook.ChangeLink _
"\\manches-user1\Common\FINANCE\Forecasting\FY2007\0307\OpsPlan\0307JudgementPaperLinksv001.xls", _
"\\manches-user1\Common\FINANCE\Forecasting\FY2006\1106\OpsPlan\1106JudgementPaperLinksv003.xls", xlExcelLinks
End Sub

As noted in the comment this worked. I was emboldened to try to get the
method to accept strings contained in named ranges
TextForOldLink:=
"\\manches-user1\Common\FINANCE\Forecasting\FY2007\0307\OpsPlan\0307JudgementPaperLinksv001.xls"

This is obtained from:
=E21&MID(Sheet2!$B$3,FIND("\",Sheet2!$B$3,20),FIND("\",Sheet2!$B$3,56)-FIND("\",Sheet2!$B$3,20)+1)&MID(Sheet2!$B$3,FIND("[",Sheet2!$B$3,1)+1,FIND("]",Sheet2!$B$3,1)-FIND("[",Sheet2!$B$3,1)-1)

TextForNewLink:=
“\\manches-user1\Common\FINANCE\Forecasting\FY2006\1106\OpsPlan\1106JudgementPaperLinksv003.xls”

This is obtained from
=CONCATENATE($E$23,$C$5,$C$7,"\",$D$9&$D$7,"\OpsPlan\",$D$9&$D$7,"JudgementPaperLinks"&$D$11)

An earlier respondent (Jay) suggested that the following would work

Sub UpdateLink1()
With ActiveWorkbook
.ChangeLink _
.ActiveSheet.Range("TextForOldLink").Value , _
.ActiveSheet.Range("TextForNewLink").Value, xlExcelLinks
End With
End Sub

However I get the error message: 'Compile error: argument not optional’.

Jay has unfortunately stopped monitoring the thread and I have been unable
to proceed further.

Essentially I just want to pass the contents of a named range (a string) as
an argument of the ChangeLink Method. I would be grateful if someone could
check the syntax and offer advice on where to look next.

Regards

Phil Smith


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Worksheet with Named Ranges KC Rippstein hotmail com> Microsoft Excel Programming 2 7th Jun 2008 06:04 AM
Named ranges scope / workbook/worksheet level named ranges- changeswith variable use... christian_spaceman Microsoft Excel Programming 3 24th Dec 2007 01:15 PM
Multiple worksheet named ranges to PDF Cresta Microsoft Excel Programming 0 3rd Dec 2007 03:36 PM
Using worksheet templates with named ranges Jeremy Microsoft Excel Programming 1 13th Jan 2007 04:05 PM
Named Ranges not available in every worksheet Microsoft Excel Misc 2 7th May 2004 02:53 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:43 AM.