Hi Guys,
I am getting a strange bug. For some reason, it will only succeed on the alternative attempt. If it runs successfully the first time, the second time will have the 1004 error. If I get the error the first time, I can just end the debug message pop up without touching any code then run it again and it will work. I can't get my head around it....... Please help, thanks!
If (CLng(Now) - Sheet2.Range("E34").value) > -1 Then
Dim UpdateInvTableAns As Integer
UpdateInvTableAns = MsgBox("Would you like to synchronise invoice data table?", vbQuestion + vbYesNo + vbDefaultButton2, "Synchronisation Confirmation")
If UpdateInvTableAns = vbYes Then
Workbooks("StockReference.xlsm").Worksheets("InvoiceData").ListObjects("InvoiceDataTable").DataBodyRange.Copy
Sheet12.Range("A2").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
MsgBox "Invoice table successfully updated, with time stamp " & Format(Workbooks("StockReference.xlsm").Worksheets("StockList").Range("A2").value, "DD/MM/YYYY HH:MM:SS") & ".", vbInformation, "Synchronisation Successful"
Sheet2.Range("E34").value = Workbooks("StockReference.xlsm").Worksheets("StockList").Range("A2").value
End If
End If
Bookmarks