- Joined
- Jun 29, 2012
- Messages
- 4
- Reaction score
- 0
Hey guys,
I'm a new member to this forum site. I have only been using vba excel for 4 weeks and I'm having a issue with my code.
I'm trying to run a macro at a certain time of the day (lets say midnight), when the workbook is going to open when windows task scheduler opens it. However, this workbook could be opened during the day and I don't want the macro to run then. The following is the code I have written so far:
Howvever, it doesn't seem to work. I would appreciate any kind of help I can get. Thanks in advance
I'm a new member to this forum site. I have only been using vba excel for 4 weeks and I'm having a issue with my code.
I'm trying to run a macro at a certain time of the day (lets say midnight), when the workbook is going to open when windows task scheduler opens it. However, this workbook could be opened during the day and I don't want the macro to run then. The following is the code I have written so far:
Code:
Private Sub Workbook_Open()
Application.OnTime "23:30:00", "Update", "00:30:00"
End Sub
Code:
Sub Update()
Dim FirstBlankCell As Range
Set FirstBlankCell = Range("B" & Rows.Count).End(xlUp).Offset(1, 0)
FirstBlankCell.Value = 1
ThisWorkbook.Save
ThisWorkbook.Close
End Sub
Howvever, it doesn't seem to work. I would appreciate any kind of help I can get. Thanks in advance