Timer on Excel + On value change

Costas

Administrator
Staff member
Occurring every 2 minutes, in Workbook events:

JavaScript:
'src - https://stackoverflow.com/a/4349261

Private Sub Workbook_Open()
    RunEveryTwoMinutes
End Sub


In a module:

JavaScript:
Sub RunEveryTwoMinutes()
    'Add code here for whatever you want to happen
    Application.OnTime Now + TimeValue("00:02:00"), "RunEveryTwoMinutes"
End Sub



On value change on specific cell

JavaScript:
'src - https://www.extendoffice.com/documents/excel/4423-excel-run-macro-on-cell-change.html

'on code on sheet class
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$1" Then
        MsgBox (ThisWorkbook.Sheets("mydata1").Range("A1").Value) 'here gets the new cell value
    End If
End Sub



Generic GET/ SET cell value from specific workbook & worksheet

JavaScript:
Function GetValue(ws As String, xy As String)
    GetValue = ThisWorkbook.Sheets(ws).Range(xy).Value
End Function

Function SetValue(ws As String, xy As String, val As String)
     ThisWorkbook.Sheets(ws).Range(xy).Value = val
End Function
 
Top