Hi all,
Please see below.
I am adding a formula to a spreadsheet, that looks up a section in a closed workbook. This will always be the prior working day
- So if today is the 23rd, then the link should connect to the 20th - as 23rd is Monday, prior date is Friday 20th)
The user has to update the link manually, as the file date is not changing. - i.e. Bank Rec 16 Sept
.Formula = "=IFERROR(IF(ISBLANK($B3),"""",VLOOKUP(A3,'K:\Document Share\Reconciliation Work\EP Balance Daily Reconciliation\[Bank Rec 16 Sept.xlsm]Balances'!$A:$T,20,FALSE)),)"
.AutoFill Destination:=Range("T3:T" & lastrow)
Below, is my attempt to automate this
Create link to the files folder
'link to previous day rec. we are wanting to have "mainPath", so any changes to the folder name are made in the spreadsheet, not code.
mainPath1 = ActiveWorkbook.Worksheets("Instructions").Range("d17 ").Value
Set wbCopy = Workbooks.Open(mainPath)
mainPath is - K:\Document Share\Reconciliation Work\Balance Daily Reconciliation\Bank Rec 20 Sep.xlsm
Adding code for link
When the VBA adds the following, it asks you to make the link (see attached screen shot - naming convention is changed from Sept to Sep)
TDate = Date
If Weekday(Date) = vbMonday Then
TDate = TDate - 3
Else: TDate = TDate - 1
End If
With Range("T3")
.Formula = "=IFERROR(IF(ISBLANK($B3),"""",VLOOKUP(A3,'mainpath1\[Bank Rec 16 Sept.xlsm]Balances'!$A:$T,20,FALSE)),)"
.AutoFill Destination:=Range("T3:T" & lastrow)
So, How do I make [Bank Rec 16 Sep.xlsm] become [Bank rec Tdate.xlsm] and not try to auto update the link during the macro process?
Many many thanks
Bookmarks