1

I have a macro that is used to clear sales of my transaction in Excel, what i want is every night at a specific time (example 9.00PM) it automatically run this macro so i dont have to do it manually everyday. Is it possible to do that ? can someone help me thanks

this is the clear sales macro

Sub clearSales()
Dim lastRow As Long
Dim rConstants As Range

lastRow = Sheets("DaftarPenjualan").Range("A" & Rows.Count).End(xlUp).Row
Set rConstants = Sheets("DaftarPenjualan").Range("A2:H" & lastRow).SpecialCells(xlCellTypeConstants)
    rConstants.ClearContents
Sheets("2barang").Range("B10").Value = 1

End Sub

2 Answers2

0

add

Application.Ontime TimeSerial(21, 0, 0), "clearSales"

Before end Sub

As long as your excel-application is active it wil run at 9:00

EvR
  • 3,418
  • 2
  • 13
  • 23
0

If not by using TimeSerial, you should perhaps think of TaskScheduler? Look here for more info: Recurring schedule for xlsm file via TaskScheduler

bajun65537
  • 498
  • 3
  • 14