|
-
Jan 27th, 2006, 04:21 PM
#1
Thread Starter
Fanatic Member
Linking Cells in Excel
I wan to link cells in my Source.xls into my Recieving.xls workbook. I kow you can do this by the following (without code, i.e in Excel)
Open both workbooks.
Select the range on the "sending" worksheet.
edit|copy
select the range on the "receiving" worksheet that should be linked.
edit|Paste special|paste link
But can this be done withing VBA, VB or VB.Net?
-
Jan 27th, 2006, 04:30 PM
#2
Lively Member
Re: Linking Cells in Excel
Some assumptions:
Sheet that will contain the link = "NewSheet"
Cell that will contain the link = "D2"
Workbook that contains source info = "LinkedBook.xls"
Sheet in above workbook that you are linking to = "LinkedSheet"
Cell that will contain the source info = "A1"
VB Code:
Sheets("NewSheet").Range("$D$2").Formula = "='[LinkedBook.xls]LinkedSheet'!$A$1"
-
Jan 27th, 2006, 04:38 PM
#3
Re: Linking Cells in Excel
mikeyc - You will also need the full path to the source workbook
VB Code:
Sub CreateLink()
Dim sSourcePath As String
Dim sSourceBook As String
Dim sSourceSheet As String
Dim sSourceRange As String
Dim sFullAddress As String
sSourcePath = "C:\Files\" 'Put the complete path to you source workbook here
sSourceBook = "YourSourceWorkbook.xls" 'put the name of your source workbook here
sSourceSheet = "YourSheetname" 'put the name of your sdource worksheet here
sSourceRange = "B12" 'put the address of the source cell here
sFullAddress = "='" & sSourcePath
sFullAddress = sFullAddress & "[" & sSourceBook & "]"
sFullAddress = sFullAddress & sSourceSheet & "'!"
sFullAddress = sFullAddress & sSourceRange
Range("C1").Formula = sFullAddress 'Put the cell where you want the link here
End Sub
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
Jan 27th, 2006, 04:45 PM
#4
Re: Linking Cells in Excel
Although you don't need the full path if the workbook you're looking for is in the same folder or a subfolder of the folder from which you're running the spreadsheet.
zaza
-
Jan 27th, 2006, 07:01 PM
#5
Thread Starter
Fanatic Member
Re: Linking Cells in Excel
So if I have a bunch of Spreadsheets in the same folder named EXCELLINKS I dont need the full path just the workbook name?
-
Jan 28th, 2006, 04:57 AM
#6
Re: Linking Cells in Excel
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|