Increment a cell value with a timer

泪湿孤枕 提交于 2021-01-29 06:59:53

问题


Kindly help me on solving the following requirement.

In my sheet , say in cell A1 the value of the cell needs to be incremented by 1 till it equals the value of B1. Cell B1 value would be 10.

When Incremental value of cell A1 reaches 10, the incremental loop needs to restart from 1 again. The value of cell A1 should increment every minute.

I have tried the this with the following formula. I have a macro to refresh excel by 1 minute. =IF((a1+1)<=b1,(a1+1),1) Works fine but returns the circular reference error. So I was wondering whether VBA can do this for me in background

Regards Dilan


回答1:


You need VBA to do that. You need to check value of A1 and compare it with B1 then increment or restart value of A1. Try below sub. You have to insert below codes inside your refresh sub.

Sub inc()
    If Range("A1") < Range("B1") Then
        Range("A1") = Range("A1") + 1
    Else
        Range("A1") = 1
    End If
End Sub


来源:https://stackoverflow.com/questions/63613018/increment-a-cell-value-with-a-timer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!