none
adding the cell inputs to other cell at specific time RRS feed

  • Question

  • good day,

    dear Sir/Miss,

    kindly ,I need your kind supporting to know how to adding the daily inputs of cell called (daily stock inputs) to other cells called (total balance) in same sheet. at specific time example(at 12:00 am) ,adding number to total balance of stock,and clearing the cell (daily stock inputs).at the beginning of new work day.

    thanks in advance

    Best regards

    Tuesday, January 31, 2017 11:18 AM

All replies

  • Hi Dheyaa Raheem,

    please follow the example below.

    I have 2 cells with name Dailystock and Totalstock.

    code:

    Private Sub Workbook_Open()
    Application.OnTime TimeValue("00:00:00"), "demo2"
    MsgBox ("done")
    End Sub
    Sub demo2()
    Dim cell, cell1 As Range
    Set cell = Worksheets("Sheet1").Range("Dailystock")
    Set cell1 = Worksheets("Sheet1").Range("Totalstock")
    cell1.Value = cell1.Value + cell.Value
    cell.Value = ""
    End Sub

    Output:

    it will call the sub demo2 at 12 AM.

    here I use Workbook_open event to call demo2 sub.

    so when you open the workbook it will execute and after that at 12 AM demo2 sub will execute.

    if your workbook remain open all the time  or your workbook remain close then Workbook_open event will not call next day by itself.

    it will only call only 1 time when you open the workbook.

    so in that condition you need to use Task Scheduler to call the macro.

    if you open the workbook everyday by yourself then there is no issues.

    but you need to be sure that it stays open at 12 AM. because at this time demo2 will execute.

    Reference:

    Application.OnTime Method (Excel)

    Hope you understand all the things correctly. if you have any doubt or further question then let me know about that.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Wednesday, February 1, 2017 12:42 AM
    Moderator