counter

Dannyj01

New Member
Joined
Sep 1, 2018
Messages
6
Hi folks,

Just a quick on (I hope) is there an easy way on having a dropdown list with a submit button under it and then when the button is pressed it counts up on a table in another sheet after every press of the submit button. An example of what I mean is below.

Because I dont know how to paste what I have in to here a worded example is below.

Input sheet
B11 has a drop down in it with things like GMS3 GMS1 DMS
this has a submit button below it.

On a Triage sheet is a table with headers from A1 which is the date then B2 is GMS1, C2 is GMS3 and so on up to L2 which is total for the day.

So I would like whatever is submitted from the drop down be updated on the triage sheet.

Hope this makes sense, if someone could tell me how to paste how it looks in to here I will do that as obviously a visual is easier to understand than a worded explanation.

Thankyou in advance

Daniel
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
.
Paste this in the Sheet Level Module where the button is located :

Code:
Option Explicit


Private Sub CommandButton1_Click()
    Dim arr
    Dim clks As String
    Dim wr As Long  'write row
    
arr = Split(CommandButton1.Caption, vbLf)
clks = arr(UBound(arr))
CommandButton1.Caption = "Number of clicks is" & vbLf & clks + 1


With Sheets("Sheet2")
    wr = .Cells(Rows.Count, "A").End(xlUp).Row + 1
    .Cells(wr, "A").Value = clks + 1
    .Cells(wr, "B").Value = Now
End With


End Sub




Sub ResetClicks()
Sheet1.CommandButton1.Caption = "Number of clicks is" & vbLf & "0"
'to clear sheet2 uncomment next line
'Sheets("Sheet2").UsedRange.Offset(1).ClearContents
End Sub

Download workbook : https://www.amazon.com/clouddrive/share/DhRVsANsApfzn2Q83tnhJPYOemFbRLmc9qBZEe6QrZH
 
Upvote 0
Ok cool, I will give this a go when I get back home, will this code count whatever is selected in a table on a different page? The help is much appreciated
 
Upvote 0
.
It tracks how many times the button is clicked. So, whatever macro you have attached to the button, it will count how many times the button was clicked to
activate that macro. The macro can be anything, it doesn't matter, as the code only tracks the times the button itself was clicked.
 
Upvote 0
Ahh ok, I will have to see if I can get it to work with the drop down categories, i basically need to it add 1 to a table for what ever is selected, so if I pick gms3 then I want it to add one to the tally for gms3 and so on for all 10 options
 
Upvote 0

Forum statistics

Threads
1,215,759
Messages
6,126,729
Members
449,333
Latest member
Adiadidas

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top