Search code examples
javascriptexceloffice-jsoffice-addinsexcel-addins

How to create a counter in Excel online (Excel 365)


I know to use Active X and buttons to create a counter that when clicked increments by 1 in normal Excel easily enough but excel 365(online) doesn't allow for buttons. Any idea how to create a counter in Excel online?

So I found this bit of code but I don't know Javascript. Anybody know enough that can be of help?

Public xRgS, xRgD As Range
Public xNum As Long
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    On Error Resume Next
    If Target.Cells.Count > 1 Then Exit Sub
    Set xRgS = Range("E2")
    If xRgS Is Nothing Then Exit Sub
    Set xRgD = Range("H2")
    If xRgD Is Nothing Then Exit Sub
    If Intersect(xRgS, Target) Is Nothing Then Exit Sub
    xNum = xNum + 1
    xRgD.Value = xNum
End Sub

It just keeps track of everytime you click inside a cell.


Solution

  • There are two possible ways for O365 on the web:

    I suppose web add-ins is the right choice for a custom UI (a task pane).