
PROVIDING ACCURATE, RELIABLE AND STRAIGHT TO THE POINT KNOWLEDGE ABOUT DIFFERENT IT TOOLS EXPLAINED WITH PRACTICAL EXAMPLES
CONTENTS
SIMPLE COUNTER IN EXCEL USING VBA
INTRODUCTION
OBJECTIVE
TO CREATE A SIMPLE COUNTER WITH A COUNT AND A RESET BUTTON . GRAPHICS ARE NEEDED IN SHEET ITSELF.
PRE PLANNING
USER INTERFACE
VBA PROGRAMMING
PREPARATION FOR THE PROJECT
DESIGNING THE USER INTERFACE
COUNTER
STEPS
- Select a cell and enlarge it.
- Fix the font to be 96 or bigger.
- Use the word art to give it a lovely look. (INSERT WORD ART )
- To make the digits look like a counter
- Go to the cell and right click.
- Go to format cells.
- Go to Custom and click 0000 and check if the sample becomes 0001 or not.
- Click ok
- Out counter is ready.
BUTTONS
STEPS
- Insert a Shape as you want your button to be. (INSERTING SHAPES IN EXCEL)
- Give it a lovely shape and color.
- Change its text to COUNT.
- Copy the same button and paste a little down the previous button.
- Change its name to RESET.
- Our buttons are ready too.
- The buttons we created looked somewhat like in picture shown below.
- So now the complete USER INTERFACE IS READY.
THE COMPLETE USER INTERFACE
The complete user interface looks like this.
THE COUNTER IS IN THE CELL D3. It can be in any cell but we have to change the code accordingly.
CODING VBA
CODE
‘gyankosh.net
‘simple counter
Dim A As Integer ‘module level declaration so that all the procedures can work on this.
Sub INCREMENT()
A = A + 1 ‘Incrementing the variable
Range(“D3”).Value = A ‘Setting the value in D3.
End Sub
Sub reset()
A = 0 ‘Setting the value to 0;
Range(“D3”).Value = A ‘Setting the value to cell D3
End Sub
EXPLANATION
RUNNING THE CODE AND OUTPUT
The counter is working as per expectations.
OTHER WAYS TO REACH THIS ARTICLE
WHAT IS EXCEL, HOW EXCEL WORKS, WRITE FORMULA IN EXCEL, EXAMPLE OF USING FORMULA IN EXCEL, ANIMATED EXAMLPE OF USING FORMULA IN EXCEL
YOU MAY LIKE
- HOW TO TROUBLESHOOT A FORMULA IN EXCEL?
- USE OF FONTS, FONT SIZE, INDENTATION, TEXT TO THE RIGHT, TEXT TO THE LEFT, TEXT IN THE MIDDLE ETC.
- how to insert table in excel?
- FOR MORE ARTICLES, CLICK EXCEL OR TYPE IN SEARCH BELOW.