Originally Posted by
mdmackillop
Sub MntCalculate()
lc = Cells(2, Columns.Count).End(xlToLeft).Column + 1
If lc < 11 Then lc = 11
lr = Cells(Rows.Count, 10).End(xlUp).Row - 1
With Cells(2, lc).Resize(lr)
.FormulaR1C1 = "=RC10"
.Value = .Value
End With
Application.OnTime Now + TimeValue("00:01:00"), "Sheet1.MntCalculate"
End Sub
Well, I tried something like this:
Sub MntCalculate()
LC = Application.MAX(11, Cells(2, Columns.Count).End(xlToLeft).column + 1)
For i = 2 To 218
Cells(i, LC) = Range("J" & i)
Next i
Application.OnTime Now + TimeValue("00:01:00"), "Sheet1.MntCalculate"
End Sub
And, it was working, until I tried to put another one in the "workbook" to make this macro start at 9 AM and end at 3.30 PM every Monday to Friday.
Private Sub Workbook_Open()
If Day(Date) > 1 And Day(Date) < 7 Then
Application.OnTime TimeValue("09:00:00"), _
"Sheet1.MntCalculate", TimeValue("15:30:00")
Else
Application.OnTime TimeValue("09:00:00"), _
"Sheet1.MntCalculate", TimeValue("15:30:00"),,False
End If
End Sub
Now, I am getting an error in the line after "Else" and cursor is highlighting "Ontime" as the culprit.
Help please....
Swarnendu