Ok, so this is something which is probably so simple but I can't figure it out. I need a macro to create a linked cell to another workbook. The name of the workbook will change every time. The other workbook gets assigned a name based on a value they type into a form at the beginning, which is then stored as a variable (ProjectNum). I just want it to display the value of a specific cell on that other workbook as a linked cell (the value will change periodically and this file needs to be able to see updates).
So the macro recorder gave me this when I did a test run:
But that uses a static name for the workbook so I tried splitting it up using & and inserting the variable name where the workbook should go like this but it didn't work (the real workbook name won't have any spaces)
The closest I've gotten is this (it inserts the complete file path ProjectDir and the file name which is a variable), but it opens a file dialog and called Update Values and makes me select the file (if I do, it works, if not, it doesn't). I don't want to have to select the file though.
Any help you could provide would be much appreciated
So the macro recorder gave me this when I did a test run:
Code:
ActiveCell.FormulaR1C1 = "='[Visboard Template Questions.xlsm]New'!R2C17"
But that uses a static name for the workbook so I tried splitting it up using & and inserting the variable name where the workbook should go like this but it didn't work (the real workbook name won't have any spaces)
Code:
ActiveCell.FormulaR1C1 = "=[" & ProjectNum & ".xlsm]" & ProjectNum & "!R2C17"
The closest I've gotten is this (it inserts the complete file path ProjectDir and the file name which is a variable), but it opens a file dialog and called Update Values and makes me select the file (if I do, it works, if not, it doesn't). I don't want to have to select the file though.
Code:
ActiveCell.Value = "='" & ProjectDir & "[" & ProjectNum & "]" & ProjectNum & "'!Q2"
Any help you could provide would be much appreciated