You are here:

Excel/Count Clicks of Spin Buttons

Advertisement


Question
QUESTION: Hi Edward,

I have inserted a scroll Bar in excel sheet.
Developer-->Insert-->Spin Button
I gave Cell Link of that button to A1 by right clicking on it then format control.

So now when I Click on Up Arrow, Number increases and when I Click down Arrow, Number decreases.

Can I set a counter in Cell A2 that counts How many times I have clicked the button?

Thanks

ANSWER: (question found in question pool)

you will need to use some VBA to do this, but that's fairly easy - in design mode, right click the control and select view code.  Enter this

Range("A2").Value = Range("A2").Value + 1


in the spinbutton change event - it will then count one for every time the button is clicked in either direction.

---------- FOLLOW-UP ----------

QUESTION: Hi Aidan,

Thanks for picking up my question.
I am New to VBA.
Can you explain step-by-step.

Thanks

Answer
I can try to do it step by step, though I did think I more or less had!  Developer ribbon, then use the design mode button to get the controls into design.  Right click the spin button control and you will have a view code option - left click that - it will put you into the change event of the control automatically, so you then just need to paste (or type!) my code in - which simply says put into A2 whatever you find in A2 plus 1
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


Aidan Heritage

Expertise

I have provided first hand support since `95 for Microsoft Office majoring in Word and Excel - support for all versions from 2 onwards. I'm based in the UK, so please allow for time differences when asking me questions from other parts of the world!

Experience

My background is in the insurance industry and call centre areas, but have been called upon to provide many varied solutions.

Education/Credentials
I'm educated to UK A level standard, but as I left school some 30 years ago that is rather irrelevent - university of life has provided more of a background!

©2016 About.com. All rights reserved.