Hi all hoping you may be able to offer advice; apologise if numpty question but its got me flummoxed
I have a number (>100) of excel workbooks (consistent format) on a server and I am trying to create a master spreadsheet with links to specific cells. I started using formulae based on Concatenate and Indirect functions but always had to use F2 & F9 to get a result. I am now working on a macro to build semi dynamic links, I am some way there but need some expert help please.
In Col A I have the path and file name for all my source files - I have used the Filename *.xls & FoundFiles for this.
In Col B is my specific file name(s) extracted from Col A using an If , Len and Text function.
My macro declares variables; File = Range (B#) and Data(21) - an array of 21 specific worksheet cell references
I then select C1 and with active.formula insert the consistent path, File and Data(1). Then C2 with path name, File and Data(2). Then C3 path name, File and Data(3). & So on for the 21 variables in the array - not elegant but it works okay
I am now at the point where I need to move down the rows and repeat this for each source. I am wondering (hoping ) there is a simple way of offsetting this for the 100 rows / source files. I would also like to be able to set the offset repeat by counting the number of populated rows in Col A.
The code (from memory so syntax may be a bit wonkey):
Option Base 1
Sub GetData()
Dim File, Data(21) As String
Data(1) = "Sheet1'!$E$10"
Data(2) = "Sheet1'!$E$12"
Data(3) = "Sheet1'!$E$15"
Data(4) = "Sheet1'!$E$20"
FileX = Range("B1") 'first row / input sheet
Range("E1").Select
ActiveCell.Formula = "='path\[" & File & "]" & Data(1)
Range("F1").Select
ActiveCell.Formula = "='path\[" & File & "]" & Data(2)
Range("G1").Select
ActiveCell.Formula = "='path\[" & File & "]" & Data(3)
Range("H1").Select
ActiveCell.Formula = "='path\[" & File & "]" & Data(4)
FileX = Range("B2") 'next row
Range("E2").Select
ActiveCell.Formula = "='path\[" & File & "]" & Data(1)
Range("F2").Select
ActiveCell.Formula = "='path\[" & File & "]" & Data(2)
Range("G2").Select
ActiveCell.Formula = "='path\[" & File & "]" & Data(3)
Range("H2").Select
ActiveCell.Formula = "='path\[" & File & "]" & Data(4)
End Sub
Any pointers on this much appreciated
Hope this make sense - ta muchly D:-)
Bookmarks