When I say the link "breaks" when using the INDIRECT function I mean that it gives a #REF error. Here is the function I'm using to link from Book1 to Book2:
=INDIRECT("'[Book2.xls]" & MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,99)& "'!L8")
When I enter this in a cell on Book1 that I want linked to Book2, it does so correctly; however, when I sort my worksheet on Book1 the links then return #REF errors in the cell. Also, when reviewing the formula after sorting, this is the entry:
=INDIRECT("'[Book2.xls]" & MID(CELL("filename",#REF!),FIND("]",CELL("filename",#REF!))+1,99)& "'!L8")
When I saw that (just now as of posting this), I simply put $A$1 instead of A1 and it seems to work - I have not yet completed checking it as I have 20 columns of 24 rows of information that the function must be placed into, and when using auto-fill it does not change the linked cell on Book2 (the L8) so I must do each manually (unless you know a faster way maybe?). It does seem this is the only way to accomplish what I want; however, now I have the issue of the other Book2 needing to be opened along with Book1 (I figure I can have a macro accomplish that - to automatically open Book2 when Book1 is opened), and my other problem is that when a new row of information is added to Book2, I have to manually paste and modify the INDIRECT formula in Book1 - and I will not be the primary end-user of this workbook system. Is there any way to make a more streamlined approach to adding a new INDIRECT function to Book1 that links to the new rows added to Book2?
P.s. - You mention adding coding in my macro that would automatically change the links from Wk1 to Wk2; that would be the ideal fix for me; however, the sheet being copied must have that action take place only on cells that have certain criteria (I don't want all the cells on the sheet to be changed, just certain ones). I have been provided a macro that accomplishes something like that (it clears cells that meet a given criteria, or populates a formula into those cells in another modification), but it may be overly complex to try addressing both potential solutions right now. I really don't have too much of a problem needing Book2 to be opened at the same time Book1 is opened (assuming I can have a macro do so automatically when Book1 is opened). If use of the INDIRECT function proves to be inadequate, perhaps then I will pursue obtaining assistance modifying my code (I don't know which solution would be easier / more effective). If you think that would be the most prudent course of action (instead of using INDIRECT), here is the code I referenced - there are actually two. The first clears cells based of the value in cell D1, the second populates a formula into cells based off cell D1:
Sub ClearCellCond()
Dim MyRange As Range, MyText As String
MyText = Range("D1").Value
LastRow = Cells(Rows.Count, "W").End(xlUp).Row
Set MyRange = Range("W8:W" & LastRow)
For Each c In MyRange
If c.Value = MyText Then
c.Offset(, -11).ClearContents
End If
Next
End Sub
Sub PutWCond()
Dim MyRange As Range, MyText As String
MyText = Range("D1").Value
LastRow = Cells(Rows.Count, "W").End(xlUp).Row
Set MyRange = Range("W8:W" & LastRow)
For Each c In MyRange
If c.Value = MyText Then
c.Offset(, -11).FormulaR1C1 = "=IF(ISTEXT(RC[-1]),""W"","""")"
End If
Next
End Sub
Thanks again for your help.
CVinje
Bookmarks