In this code workbook ("1.xlsm") is in folder named "3. March 2019" and workbook [29.xlsm] is in folder named "2. February 2019". I have a command button to run this code. The problem is that when I click it workbook ("1.xlsm") is not updating from workbook ("29.xlsm") but it is opening workbook ("2.xlsm") of folder "3. March 2019". I tried to find if there is something wrong in the code but I can't manage.
Code: Select all
Sub SO()
Dim strPath As String
strPath = CreateObject("WScript.Shell").SpecialFolders("MyDocuments")
dateStamp = Date
If Not Range("Q1").Value = dateStamp Then
Range("Q1").Value = dateStamp
'// replace with your code below-------------
Workbooks("1.xlsm").Sheets("Chit1&2").Range("E20:H21").Value = "=" & "'" & strPath & "\My System\2. February 2019\[29.xlsm]Chit1&2'!E20:H21"
Workbooks("1.xlsm").Sheets("Chit3&4").Range("E20:H21").Value = "=" & "'" & strPath & "\My System\2. February 2019\[29.xlsm]Chit3&4'!E20:H21"
Workbooks("1.xlsm").Sheets("Chit5&6").Range("E20:H21").Value = "=" & "'" & strPath & "\My System\2. February 2019\[29.xlsm]Chit5&6'!E20:H21"
Workbooks("1.xlsm").Sheets("Chit1&2").Cells(8, "J").Value = "=" & "'" & strPath & "\My System\2. February 2019\[29.xlsm]Chit1&2'!J8"
Workbooks("1.xlsm").Sheets("Chit3&4").Cells(8, "J").Value = "=" & "'" & strPath & "\My System\2. February 2019\[29.xlsm]Chit3&4'!J8"
Workbooks("1.xlsm").Sheets("Chit5&6").Cells(8, "J").Value = "=" & "'" & strPath & "\My System\2. February 2019\[29.xlsm]Chit5&6'!J8"
MsgBox "Code run for first time today!"
Else
MsgBox "Code has already been run today!"
End If
End Sub
Thanks in advance.