speed88bump
New Member
- Joined
- Aug 9, 2013
- Messages
- 29
The basic purpose of what I am doing is I have a Target workbook with cells linked to Source WB and when I update the source I want it to update the Target Automatically every minute. The Target WB also has a countdown timer in it and when it reaches zero it processes the update.
The Target WB has the codes in it and it is opened and viewed on a monitor from another PC. The Source WB is on my PC when I update it, the Macro on the Target updates which is great. However, I keep receiving random error messages that when fixed it will work for an hour or two and then another error pops up. (You know how frustrating this can be when you have the evil doubters on the wing ready to pounce when it doesn't work). All because they don't understand it. Anyway, sorry about that back to business. I am using Excel 2010 and here is the code.
ThisWorkbook Module Consist of:
Option Explicit
Sub Workbook_Open()
Dim StopTimer As Boolean
Call Update_Links
'Start the timer
Const Minutes = 1
Dim EndTime As Double
StopTimer = False
Do
If EndTime - Now < 0 Then
Call Update_Links
EndTime = Now + TimeSerial(0, Minutes, 0)
End If
ThisWorkbook.ActiveSheet.Range("B1") = EndTime - Now ***
DoEvents
Loop Until StopTimer
End Sub
Sub Workbook_Close()
Dim StopTimer As Boolean
StopTimer = True
End Sub
A separate Module contains:
Sub Update_Links()
On Error Resume Next
ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources
End Sub
Sub Workbook_Stop()
Dim StopTimer As Boolean
StopTimer = True
End Sub
The item with 3 asteriks next to it is where I receive most errors from.
ThisWorkbook.ActiveSheet.Range("B1") = EndTime - Now ***
Usually a compile error. Originally it was just Range("B1") then I changed it to ActiveSheet.Range("B1") after another error I changed it to Thisworkbook.ActiveSheet.Range(B1")
I have to use ActiveSheet because there are 7 worksheet tabs on the Target WB one for each day.
Range("B1") contains a count down timer. Update_Links well.... Updates the Links.
Is their a cleaner way of writting this to make it solid and not error out everytime someone looks at it funny.
FYI... The Target WB is the only open Excel WB on this monitor.
The Target WB has the codes in it and it is opened and viewed on a monitor from another PC. The Source WB is on my PC when I update it, the Macro on the Target updates which is great. However, I keep receiving random error messages that when fixed it will work for an hour or two and then another error pops up. (You know how frustrating this can be when you have the evil doubters on the wing ready to pounce when it doesn't work). All because they don't understand it. Anyway, sorry about that back to business. I am using Excel 2010 and here is the code.
ThisWorkbook Module Consist of:
Option Explicit
Sub Workbook_Open()
Dim StopTimer As Boolean
Call Update_Links
'Start the timer
Const Minutes = 1
Dim EndTime As Double
StopTimer = False
Do
If EndTime - Now < 0 Then
Call Update_Links
EndTime = Now + TimeSerial(0, Minutes, 0)
End If
ThisWorkbook.ActiveSheet.Range("B1") = EndTime - Now ***
DoEvents
Loop Until StopTimer
End Sub
Sub Workbook_Close()
Dim StopTimer As Boolean
StopTimer = True
End Sub
A separate Module contains:
Sub Update_Links()
On Error Resume Next
ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources
End Sub
Sub Workbook_Stop()
Dim StopTimer As Boolean
StopTimer = True
End Sub
The item with 3 asteriks next to it is where I receive most errors from.
ThisWorkbook.ActiveSheet.Range("B1") = EndTime - Now ***
Usually a compile error. Originally it was just Range("B1") then I changed it to ActiveSheet.Range("B1") after another error I changed it to Thisworkbook.ActiveSheet.Range(B1")
I have to use ActiveSheet because there are 7 worksheet tabs on the Target WB one for each day.
Range("B1") contains a count down timer. Update_Links well.... Updates the Links.
Is their a cleaner way of writting this to make it solid and not error out everytime someone looks at it funny.
FYI... The Target WB is the only open Excel WB on this monitor.