lazycreeks
Technical User
In Excel 2000, DDE data updates and causes frequent automatic recalculation. Formulas thus update, filling two ranges with data to drive two charts. When the range for chart 2 is full, Cell "I70" returns the value 1, and when chart 3 range is full, Cell "I134" returns the value 1.
In my worksheet is the following code;
Private Sub Worksheet_Calculate()
Call Print_Control
End Sub
In the Print_Control module, as soon as the first "If..." statement condition is met, the code needs to change the value in Cell "I70", or "I134" to 0 to prevent re-calling the same macro (on recalculation) before it executes one time.(turning off automatic calculation prevents incoming DDE data from being analyzed and processed while its off)
Then the line to actually call the Print_2 or Print_3 macros.
PROBLEM. Most of the time, the error 13 type mismatch trips on the "If...Then" statement line in Print_Control. Nor does
"If Range("I70"
.Value = 1 Then" work any better.
Using Dim OK2Print As Integer, I can't use the "Set" command to define the cell location of "OK2Print".
QUESTION. I'd like to bypass calling the Print_Control sub by using an "If...Then" statement, or something - anything that calls directly from Private Sub Worksheet_Calculate when cell "I70" or "I134" = 1, but this is beyond me.
The actual print macros work fine, I just can't call them reliably when the worksheet is ready to print 1 or both charts - no matter what I do or where I put it. Since I need this to work unattended, I can't use a worksheet button or other user input. This sometimes works for a short while if I can "reset" the macro while DDE is coming in, but I need to get the code right at compile time.
Sub Print_Control()
Dim OK2Print2 As Object
Dim OK2Print3 As Object
Set OK2Print2 = Worksheets("Sheet1"
.Range("I70"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Set OK2Print3 = Worksheets("Sheet1"
.Range("I134"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
If OK2Print2.Value = "1" Then
OK2Print2.FormulaR1C1 = "0"
Call Print_2
Else:
If OK2Print3.Value = "1" Then
OK2Print3.FormulaR1C1 = "0"
Call Print_3
End If
End If
End Sub
I have labored over this for weeks, and can't find where to learn the solution, so thanks in advance for any help here. Kudos to RobBroekhuis especially and others for all that I have learned by reading this and other forums.
In my worksheet is the following code;
Private Sub Worksheet_Calculate()
Call Print_Control
End Sub
In the Print_Control module, as soon as the first "If..." statement condition is met, the code needs to change the value in Cell "I70", or "I134" to 0 to prevent re-calling the same macro (on recalculation) before it executes one time.(turning off automatic calculation prevents incoming DDE data from being analyzed and processed while its off)
Then the line to actually call the Print_2 or Print_3 macros.
PROBLEM. Most of the time, the error 13 type mismatch trips on the "If...Then" statement line in Print_Control. Nor does
"If Range("I70"
Using Dim OK2Print As Integer, I can't use the "Set" command to define the cell location of "OK2Print".
QUESTION. I'd like to bypass calling the Print_Control sub by using an "If...Then" statement, or something - anything that calls directly from Private Sub Worksheet_Calculate when cell "I70" or "I134" = 1, but this is beyond me.
The actual print macros work fine, I just can't call them reliably when the worksheet is ready to print 1 or both charts - no matter what I do or where I put it. Since I need this to work unattended, I can't use a worksheet button or other user input. This sometimes works for a short while if I can "reset" the macro while DDE is coming in, but I need to get the code right at compile time.
Sub Print_Control()
Dim OK2Print2 As Object
Dim OK2Print3 As Object
Set OK2Print2 = Worksheets("Sheet1"
Set OK2Print3 = Worksheets("Sheet1"
If OK2Print2.Value = "1" Then
OK2Print2.FormulaR1C1 = "0"
Call Print_2
Else:
If OK2Print3.Value = "1" Then
OK2Print3.FormulaR1C1 = "0"
Call Print_3
End If
End If
End Sub
I have labored over this for weeks, and can't find where to learn the solution, so thanks in advance for any help here. Kudos to RobBroekhuis especially and others for all that I have learned by reading this and other forums.