A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Links and Linking
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Dynamic link to workbook



 
 
Thread Tools Display Modes
  #1  
Old October 18th, 2007, 04:34 PM posted to microsoft.public.excel.programming,microsoft.public.excel.links
[email protected]
external usenet poster
 
Posts: 2
Default Dynamic link to workbook

I have a overview workbook (Status.xls) were I compile data from other
source workbooks (artnr1.xls, art.nr2.xls, ...). All source workbooks
look the same, it's just the data that differs. When a new source
workbook is created it's saved as [article number.xls] eg, 11134.xls

In the overview workbook I've listed the data according to;

A B C D ...
Art1 Data1 Data2 Data3 ...'¨
Art2 Data1 Data2 Data3 ...
Art3 Data1 Data2 Data3 ...
Art4 Data1 Data2 Data3 ...

What I want is, when I write a new article in the A column (eg.
11134), data should be collected from the workbook with corresponding
file name =11134.xls

This should happen automaticly without having to modify or copy the
formula for every new article that's created.
I've gotten this to work with =INDIRECT but then every workbook have
to be open and then you've lost the purpose.

Is there any way to solve this problem or do you have to copy and
modify the formula for every new article that's added? How can you
(with vb) take the art.nr and use it in the link.

The formula will always be eg. [xxxxx.xls]Sheet1'!$D$5 so when I input
eg. 11134 as for a new article I want the formula to change to
[11134.xls]Sheet1'!$D$5.

What I need is =INDIRECT but with the functionallity of a ordinary
external link that askes for update when you open the document and
holds that value until you update again.

best regards
/Peter

  #2  
Old October 20th, 2007, 12:18 AM posted to microsoft.public.excel.programming,microsoft.public.excel.links
Bill Manville
external usenet poster
 
Posts: 258
Default Dynamic link to workbook

Through the UI, just copy an entire row (say for art 11111 to the
bottom of your summary table then select the new row and Edit / Replace
/ 11111 / with: 11134 / Replace All.

If you wanted to use a macro, you could detect a change in column 1 of
the worksheet and copy the row above, and then do the replace, as
above. Something like this, in the worksheet's module

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 And Target.Cells.Count = 1 And Not
IsEmpty(Target) And Target.Row 1 Then
' copy down the formulas from the row above
With Target.Offset(, 1).Resize(, Columns.Count - 1)
.FillDown
.Replace Target.Offset(-1).Value, Target.Value, xlPart
End With
End If
End Sub


Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - respond to newsgroup

  #3  
Old October 24th, 2007, 01:18 PM posted to microsoft.public.excel.programming,microsoft.public.excel.links
[email protected]
external usenet poster
 
Posts: 2
Default Dynamic link to workbook

On 20 Okt, 01:18, Bill Manville wrote:
Through the UI, just copy an entire row (say for art 11111 to the
bottom of your summary table then select the new row and Edit / Replace
/ 11111 / with: 11134 / Replace All.

If you wanted to use a macro, you could detect a change in column 1 of
the worksheet and copy the row above, and then do the replace, as
above. Something like this, in the worksheet's module

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 And Target.Cells.Count = 1 And Not
IsEmpty(Target) And Target.Row 1 Then
' copy down the formulas from the row above
With Target.Offset(, 1).Resize(, Columns.Count - 1)
.FillDown
.Replace Target.Offset(-1).Value, Target.Value, xlPart
End With
End If
End Sub

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - respond to newsgroup


-----------------------------------------------------------------

Thanks Bill, workes like a charm + a very clean script!!!

I run into a new problem that I'm hoping you also could help me with.
Prior I've used a script (se bellow) to find and list files in a
specified directory. Now, I want to look into a URL insted of a
folder. I've tried by changing the line;
..LookIn = "F:\"
to
..LookIn = "URL;http..."
but this doesn't work

Do you have any idea on how to make this work?

Best regards
/Peter

---------------------------------------------------------------
Dim pathWanted As String
With Application.FileSearch
.NewSearch
.LookIn = "F:\"
.SearchSubFolders = True
.MatchTextExactly = False
.FileType = msoFileTypeAllFiles
If .Execute() 0 Then
For i = 1 To .FoundFiles.Count
Cells(i, 1).Value = .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With
---------------------------------------------------------------

  #4  
Old October 25th, 2007, 08:38 AM posted to microsoft.public.excel.programming,microsoft.public.excel.links
Bill Manville
external usenet poster
 
Posts: 258
Default Dynamic link to workbook

Now, I want to look into a URL insted of a
folder. I've tried by changing the line;
..LookIn = "F:\"
to
..LookIn = "URL;http..."
but this doesn't work


I'm not surprised it doesn't work - any more than it does in File
Open or in Windows Explorer's address bar.

I don't think it's possible to access a Windows file system via a URL
which is presumably what you are trying to do. But I'm not an expert
on web matters.

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - respond to newsgroup

 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:49 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.