ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Linking to user specified file (https://www.excelbanter.com/excel-programming/382748-linking-user-specified-file.html)

[email protected]

Linking to user specified file
 
I want to link cell A1 in workbook1 to more than one workbook. I
actually want a procedure to ask the user to specify which workbook to
link to. How can I do this? Can I automate this so that the user
specifies the file and updates cells ?


Tom Ogilvy

Linking to user specified file
 
Sub CreateLink()
Dim rng as Range, bk as Workbook
Dim fName as Variant
set rng = activecell.parent.Range("A1")
fname = application.GetOpenFileName()
if fName = False then exit sub
set bk = workbooks.open(fName)
bk.Worksheets(1).Range("A1").Formula = "=" & _
rng.Address(1,1,xlA1,True)
bk.Close Savechanges:=True
End Sub

--
Regards,
Tom Ogilvy

" wrote:

I want to link cell A1 in workbook1 to more than one workbook. I
actually want a procedure to ask the user to specify which workbook to
link to. How can I do this? Can I automate this so that the user
specifies the file and updates cells ?



[email protected]

Linking to user specified file
 
Could you tell me what exactly this code is doing ? I am not sure if I
am getting the desired result..


On Feb 7, 11:27 am, Tom Ogilvy
wrote:
Sub CreateLink()
Dim rng as Range, bk as Workbook
Dim fName as Variant
set rng = activecell.parent.Range("A1")
fname = application.GetOpenFileName()
if fName = False then exit sub
set bk = workbooks.open(fName)
bk.Worksheets(1).Range("A1").Formula = "=" & _
rng.Address(1,1,xlA1,True)
bk.Close Savechanges:=True
End Sub

--
Regards,
Tom Ogilvy



" wrote:
I want to link cell A1 in workbook1 to more than one workbook. I
actually want a procedure to ask the user to specify which workbook to
link to. How can I do this? Can I automate this so that the user
specifies the file and updates cells ?- Hide quoted text -


- Show quoted text -




Tom Ogilvy

Linking to user specified file
 
it creates a link from the workbook selected by the user back to A1 of the
activesheet when you run the macro. the link is established in cell A1 of
the first sheet in the workbook specified.

I want to link cell A1 in workbook1 to more than one workbook.


so your Workbook1 should be the activeworkbook when you run the macro.

--
Regards,
Tom Ogilvy



" wrote:

Could you tell me what exactly this code is doing ? I am not sure if I
am getting the desired result..


On Feb 7, 11:27 am, Tom Ogilvy
wrote:
Sub CreateLink()
Dim rng as Range, bk as Workbook
Dim fName as Variant
set rng = activecell.parent.Range("A1")
fname = application.GetOpenFileName()
if fName = False then exit sub
set bk = workbooks.open(fName)
bk.Worksheets(1).Range("A1").Formula = "=" & _
rng.Address(1,1,xlA1,True)
bk.Close Savechanges:=True
End Sub

--
Regards,
Tom Ogilvy



" wrote:
I want to link cell A1 in workbook1 to more than one workbook. I
actually want a procedure to ask the user to specify which workbook to
link to. How can I do this? Can I automate this so that the user
specifies the file and updates cells ?- Hide quoted text -


- Show quoted text -






All times are GMT +1. The time now is 02:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com