PDA

View Full Version : Count button clicks and write them to a file or sheet with time and date index



Purplelama
12-23-2014, 03:45 AM
Hi

the title kind of says it all.

We are using an Excel for printing labels, that are posted on papers.

We got 27 different labels, all are printed with barcodes via buttons on the Excel VBA including a small GUI.

What I would like to do is, that every single click is counted with a date and time index. I need to know at the end of the day, how many times each of those 27 labels have been clicked and when.

I will create pivot tables out of that data later on, for analysis.

Any ideas how I could do that?

Thank's!

Kenneth Hobs
12-23-2014, 07:50 AM
Welcome to the forum!

For an ActiveX or Userform command button's code:

Private Sub CommandButton1_Click()
Track "Command Button 1"
End Sub
In a Module:

Sub Track(sID As String) Dim r As Range
With Sheet2 'or Worksheets("Sheet2") or...
Set r = .Range("A" & Rows.Count).End(xlUp).Offset(1)
With r
.Value = sID
.Offset(, 1).Value = Now
.Offset(, 1).NumberFormat = "mm/dd/yyyy hh:mm:ss AM/PM"
.Offset(, 2) = Environ("username")
End With
End With
End Sub

Purplelama
12-24-2014, 08:39 AM
To be honest, I have no clue about VBA... I know some coding from years ago.

However, I just found out, that the clickable buttons are created from Excel Sheets within that file. Can you have a look at this? Maybe it helps...

12660