How to Count Frequency of Text in Excel (Using VBA)!

Similar documents
- creating the pong bat animation with various options

Grips, preparation. and swing path

Microsoft Windows Software Manual for FITstep Stream Version 4

Complete Wristband System Tutorial PITCHING

In this assignment, students will analyze statistics from the U.S. Department of Transportation to determine the safest means of travel.

Section 5 Critiquing Data Presentation - Teachers Notes

Background Information. Project Instructions. Problem Statement. EXAM REVIEW PROJECT Microsoft Excel Review Baseball Hall of Fame Problem

INSTRUCTIONS FOR USING HMS 2016 Scoring (v1)

Lesson 3 Part 1 of 2. Demonstrating and Describing the Forehand Drive Components. Purpose: National Tennis Academy

C# Tutorial - Create a Pong arcade game in Visual Studio

Adobe Captivate Monday, February 08, 2016

Module 3 Developing Timing Plans for Efficient Intersection Operations During Moderate Traffic Volume Conditions

TECHNICAL NOTE HOW TO USE LOOPERS. Kalipso_TechDocs_Loopers. Revision: 1.0. Kalipso version: Date: 16/02/2017.

P3000 Deadweight Tester Setup, Part 1: Limited Partial Correction Method

Excel Solver Case: Beach Town Lifeguard Scheduling

Another window pops up where you can input some parameters (called System Preferences) for your team as shown

Tac-Tic Wrist Trainer

Learn to Play Tennis in Minutes

Using the Sailwave Results Programme April 2016

USA Jump Rope Tournament Software User Guide 2014 Edition

Microsoft Excel To Model A Tennis Match

Step One - Visiting the School Zone:

EXPLOSIVE STORAGE CAPACITY CALCULATING TOOL USER MANUAL

NCSS Statistical Software

Blackwave Dive Table Creator User Guide

2012 CALIFORNIA PHYSICAL FITNESS TEST. e-template REFERENCE GUIDE

10 Steps to a Better Volley

Software Manual for FITstep Pro Version 2

ADVANCED TACTICS: CONCEPTS, FEATURES AND 5 GAME SITUATIONS

Excel 2013 Pivot Table Calculated Field Greyed Out

3. EXCEL FORMULAS & TABLES

Lab 5: Descriptive Statistics

Working with Marker Maps Tutorial

Mac Software Manual for FITstep Pro Version 2

USA Jump Rope Regional Tournament Registration User Guide 2014 Edition

8 Steps To A Modern Forehand Technique

Multi Class Event Results Calculator User Guide Updated Nov Resource

Online League Management lta.tournamentsoftware.com. User Manual. Further support is available online at

Introducing Version 7R2

Boyle s Law: Pressure-Volume Relationship in Gases

UNDERGROUND SURVEY WITH MINEMODELLER

PCS Claim Member with Dependent Travel

USER GUIDE. Download the latest version at: v by Rob Rubin

NCBA PLAYER REGISTRATION INSTRUCTIONS

PHED 151 Introduction to Tennis (1) Fall None Online information (see below) 1. Explain and demonstrate appropriate tennis strokes.

Review questions CPSC 203 midterm 2

New Captain & Player s Guide to USTA League Tennis

TENNIS SPORT RULES. Tennis Sport Rules. VERSION: June 2018 Special Olympics, Inc., All rights reserved.

Free Computer Design Tools For The Richard Joyner Offset Pendant Chucks By: Bill Kloepping, February 2018

DATA SCIENCE SUMMER UNI VIENNA

USER MANUAL April 2016

Tutorial for the. Total Vertical Uncertainty Analysis Tool in NaviModel3

Overview. Learning Goals. Prior Knowledge. UWHS Climate Science. Grade Level Time Required Part I 30 minutes Part II 2+ hours Part III

SWIM MEET MANAGER 5.0 NEW FEATURES

[MYLAPS INTEGRATION]

Overview 1. Handicap Overview 12. Types of Handicapping...12 The Handicap Cycle...12 Calculating handicaps...13 Handicap Nomenclature...

RUNNING A MEET WITH HY-TEK MEET MANAGER

Pegas 4000 MF Gas Mixer InstructionManual Columbus Instruments

How to enter a scorecard into Play Cricket

Swing Labs Training Guide

Guideline Public Company

Managing Timecard Exceptions

January 2007, Number 44 ALL-WAYS TM NEWSLETTER

GOLFNAPERVILLE.ORG YOUTH AND ADULTS

The 5 Day Serve Cure. By Jeff Salzenstein The 5 Day Serve Cure. All Rights Reserved

ADVANCED. CATIA V5 Workbook. Knowledgeware and Workbenches. Release 16. Knowledgeware. Workbenches. Richard Cozzens. Southern Utah University

IMPORTANT: Please read instructions carefully prior to use!

Separation of Acetone-Water with Aspen HYSYS V8.0

HOW TO SUBMIT YOUR RACE RESULTS ONLINE?

3. Select a colour and then use the Rectangle drawing tool to draw a rectangle like the one below.

Cricket Visualization Tool

Dance Team Tabulation Program. Instruction Manual For use with a MAC

IRBManager Instructions

SITUATION TRAINING: Build Baseline Tactics

Chromat Calibration Updated October 27th, 2017

Medway Rackets Festival skills stations

Dive Sheets & Running Events Meet Management Software Tutorial for EZMeet Version 3.1 revised 2/4/2006

Reading. 1 Look at the text. Then underline the correct words to complete the sentences about it.

Nucula. Nucula User Guide

Fencing Time Version 4.3

Dance Team Tabulation Program Instruction Manual For use with a MAC Revision 2, 11/2017

TACTICAL/TECHNICAL TOOL KIT

MIS0855: Data Science In-Class Exercise: Working with Pivot Tables in Tableau

Quintic Automatic Putting Report

A BEGINNER'S GUIDE TO SQUASH 12 TOP TIPS

BVIS Beach Volleyball Information System

MTB 02 Intermediate Minitab

Database of Winds and Waves. -internet version-

Hot Springs Village Member Portal User Guide

3. EXCEL FORMULAS & TABLES

THE AWARDS SKILLS AWARD SCHEME

CENTER PIVOT EVALUATION AND DESIGN

Combination Analysis Tutorial

Flames of War and Team Yankee Tournament Results

UNSW Tennis Club. Newsletter

The 2007 Import And Export Market For Tennis, Badminton, And Similar Rackets In Austria By Philip M. Parker

How to Setup and Score a Tournament. May 2018

SCW Web Portal Instructions

The Dream Team An Office Simulation for the Sports Minded Student 2 nd Quarter

Transcription:

Have you ever wondered how to count the frequency of text in Excel, i.e the number of times a specific text appears in a range? We have already seen how to use the different COUNTING functions in a previous tutorial. We have also seen how to use Worksheet functions in VBA code in a previous tutorial. We are now going to see how to use the COUNTIF Function, in VBA in order to retrieve the frequency of specific text. We are also going to allow user input through the use of an input box. So, let s get started with a simple example to see how to use the COUNTIF Function in VBA, in order to count the frequency of text. Table of Contents 1 Introduction 2 How to Count Frequency of Text in Excel Using VBA 3 Download Working File 4 Conclusion 5 Useful Links Introduction A grip in tennis is the way the player at hand holds the racquet, to hit shots during the match. The grips a tennis player uses or prefers influences their style of play dramatically. This is due to the fact that in tennis, grips play a role in the amount of spin and pace, the player at hand generates. There are different types of forehand grips and generally speaking, the type of grip the player prefers is dependent on the player themselves. The tennis racquet grip section is comprised of 8 bevels and these are used to help classify the type of grip. All rights reserved to ExcelDemy.com. 1

The Continental grip describes a grip where the player s index knuckle and heel pad rest on bevel 2 of the racquet. The Eastern Forehand grip describes a grip where the player s base knuckle of the index finger is on bevel 3, as is the heel pad. The Semi-Western Forehand grip describes a grip where the player s base knuckle of the index finger is on bevel 4, as is All rights reserved to ExcelDemy.com. 2

the heel pad. The Western Forehand grip describes a grip where the player s base knuckle of the index finger is on bevel 5 of the racquet, as is the heel pad. The Double-Handed Forehand grip is a grip that is obtained by holding the racket in a regular continental grip, then placing the left hand above it holding the racquet in a left-handed Semi-Western Forehand grip. This means that the reference bevels of the two hands are directly opposite one another. Famous players such as Monica Seles used the double-handed forehand grip. Read More: How to Create Combination Charts with a Secondary Axis in Excel The Eastern Backhand grip is obtained when the base knuckle of the index finger and the heel of the hand are on bevel 1. The Semi-Western Backhand grip is obtained when the base knuckle of the index finger is right on bevel 8. The Double-Handed backhand grip is obtained by holding the hand in a continental grip, then placing the left hand above in a lefthanded Semi-Western forehand grip, this means that the reference bevels of the two hands are exactly opposite each other. With the evolution of the sport different grips were popular among pro-players, during different eras of tennis. How to Count Frequency of Text in Excel Using VBA A hypothetical tennis coach is evaluating the grips of the different players, registered at the tennis clinics he runs. He wants to input a certain type of grip and see how many players at the clinic use that particular grip. The source data is shown below: All rights reserved to ExcelDemy.com. 3

1) First things first, we will create a named range in the Workbook, to encompass all the grips that have been added already for each player in the Preferred Grip column. 2) Select the cell range B6: B100, type Grips in the Name box, which is located at the left end of the formula bar and press Enter. All rights reserved to ExcelDemy.com. 4

3) Now, go to Developer>Code>Visual Basic in order to access the Visual Basic Editor (VBE). 4) Go to Insert>UserForm. All rights reserved to ExcelDemy.com. 5

5) Go to View>Properties Window in order to see the Properties Window. All rights reserved to ExcelDemy.com. 6

6) Using the Properties Window, change the name of the UserForm to frmtextfrequency, the BackColor to light yellow, the caption to See the frequency of specified text and the height to 345 and the width to 322.5. All rights reserved to ExcelDemy.com. 7

7) Insert a button on the form and using the Properties Window, change the name of the button to cmdclicktoseeinputbox, the BackStyle to 0 fmbackstyletransparent, the caption to Click to enter the grip type you want to check the frequency of, and the height to 60 and the width to 270. All rights reserved to ExcelDemy.com. 8

8) Insert a text box below the button and using the Properties Window change the name of the textbox to txtresult, set the Visible property to false and the height to 25.5 and the width to 138. All rights reserved to ExcelDemy.com. 9

9) Right-click the button and select View Code as shown. All rights reserved to ExcelDemy.com. 10

10) Enter the following code for the button click event: Dim criteriaone As String Dim rng As Range Dim countone As Integer Dim resultone As String criteriaone = InputBox( Choose the grip, you want to see the frequency of, Frequency Count ) Set rng = Worksheets( CountingtheFrequencyofText ).Range( Grips ) countone = Application.WorksheetFunction.CountIf(rng, criteriaone) All rights reserved to ExcelDemy.com. 11

resultone = mentioned & countone & times txtresult.value = resultone txtresult.visible = True Read More: VLOOKUP versus INDEX and MATCH versus DGET We want to ultimately use the COUNTIF Function in VBA, in order to tell us the frequency of a certain text. The variables are declared first in the code. The criteria will be obtained from user input in an input box and the range has been set as the named range of the workbook, which we named earlier. The text box appears with the results after the user enters the input. The visibility of the textbox is set to true again since we previously set it to false. Usually code like this requires error handling (since we are getting input from the user) but in this case, the COUNTIF Function will simply deliver 0 results if the user enters a grip that doesn t exist or spells the name of the grip wrong. 11) We will now insert another button on the form, and using the Properties Window change the name of the button to cmdcloseform, the BackColor to red, the caption to Close the Form, the ForeColor to white (this changes the font color to white) and the height to 30 and the width to 90. All rights reserved to ExcelDemy.com. 12

12) Right-click the newly added button, and choose View Code and enter the following code for the button click event: Unload Me This allows the user to close the form using this button. 13) Go back to the Worksheet, and go to Developer>Controls>Insert ActiveX Controls and choose a button and place the button on the sheet. All rights reserved to ExcelDemy.com. 13

14) Change the name of the button to cmdform and the caption to Check the Frequency of Text Form, while in Design mode. All rights reserved to ExcelDemy.com. 14

15) Right-click the newly created button on the worksheet and choose View Code and enter the following code for the button click event: frmtextfrequency.show Read More: How to Use the Database Functions in Excel 16) Return to the worksheet and make sure design mode is unchecked and click on the button to show the form. All rights reserved to ExcelDemy.com. 15

17) The textbox is not shown initially since its visibility was set to False, click the Click to enter the type of grip you want to see the frequency of, button and an input box should appear as shown below. All rights reserved to ExcelDemy.com. 16

18) Type Continental Grip in order to see the number of times Continental Grip appears in the range and then click Ok. All rights reserved to ExcelDemy.com. 17

19) The textbox appears stating the number of times Continental Grip is mentioned in the range. All rights reserved to ExcelDemy.com. 18

20) Close the form, using the red button and don t forget to save your workbook as a macroenabled workbook. And there you have it. Download Working File Counting-the-Frequency-of-Text-in-Excel Conclusion Using worksheet functions in VBA is extremely time-saving and useful, by using the COUNTIF Worksheet function in VBA and the input box in this case, we managed to get the input needed from the user as the criteria and then could count the frequency of the text. Please feel free to comment and tell us which Worksheet functions you use in your VBA code. All rights reserved to ExcelDemy.com. 19

Useful Links The different tennis grips explained The Different ways of Counting in Excel Using Worksheet Functions in VBA Referring To Ranges In Your VBA Code The Input Box 18 SHARES FacebookTwitter Taryn N Taryn is a Microsoft Certified Professional, who has used Office Applications such as Excel and Access extensively, in her interdisciplinary academic career and work experience. She has a background in biochemistry, Geographical Information Systems (GIS) and biofuels. She enjoys showcasing the functionality of Excel in various disciplines. She has over ten years of experience using Excel and Access to create advanced integrated solutions. All rights reserved to ExcelDemy.com. 20