automatically trying to run a macro at a certain time

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:

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top