Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Counting Wins and Losses.

# Counting Wins and Losses

by Allen Wyatt
(last updated June 25, 2018)

Graham has, in Excel, created a matrix of player names for his league. Cells B2:H2 contain the names of the players, as do cells A3:A9. At each intersection in the matrix, Graham places a "W" or "L" to indicate whether the match-up resulted in a win or loss for the player in each row. If a player plays another person more than once, then a cell contains a "W" or "L" for each game. Graham was wondering what formula could be used, starting in column I, to indicate the number or wins and losses for each player.

There are a number of ways you can get the desired information. One is to use this type of formula:

```=LEN(SUBSTITUTE(B3&C3&D3&E3&F3&G3&H3,"L",""))
```

This formula calculates the number of non-L characters in row 3—in other words, the number of wins. It does this by concatenating the contents of B3:H3, and then using the SUBSTITUTE function to remove all the Ls. This leaves the Ws, which are counted by the LEN function. You could also use the CONCATENATE function, in the following manner, for the same result:

```=LEN(SUBSTITUTE(CONCATENATE(B3,C3,D3,E3,F3,G3,H3),"L",""))
```

To calculate the number of losses, simply replace "L" in each formula with "W".

You can also use an array formula, which allows you to specify a range of cells to examine, rather than needing to specify every single cell:

```=SUM(LEN(SUBSTITUTE(B3:H3, "L","")))
```

This array formula, entered by pressing Shift+Ctrl+Enter, returns the number of wins (W characters) in the range B3:H3.

Finally, you can use a user-defined function to return the occurrences of a specific character within a given range. The following macro will do the trick:

```Function CharNums(r, chr) As Integer
Dim c As Range
Dim strX As String
Dim J As Integer

Application.Volatile
CharNums = 0
For Each c In r.Cells
strX = c.Value
For J = 1 To Len(strX)
If Mid(strX, J, 1) = chr Then CharNums = CharNums + 1
Next J
Next c
End Function
```

To use the function, you would us a formula like this in your worksheet:

```=CharNums(B3:H3;"W")
```

The function returns the number of uppercase W characters in the range. All other characters (including lowercase w characters) are ignored. To count losses, simply substitute L for W in the formula.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3049) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Counting Wins and Losses.

##### Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

##### MORE FROM ALLEN

Forcing Printouts to Black and White

If you want to force Word to print some of its colors in black and white, you may be out of luck. One bright spot, as ...

Discover More

Turning Off Automatic Hyphenation for Parts of a Document

Word can hyphenate documents automatically, if you want it to. But what about those situations where you want most of a ...

Discover More

Stopping Styles from Changing with Multiple Users

Using styles in your documents can be very helpful when it comes to consistency and ease of formatting. When others open ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

Listing Combinations

You can easily use the COMBIN worksheet function to determine the number of combinations that can be made from a given ...

Discover More

Splitting Cells by Case

Excel provides several different ways that you can split apart the contents of a cell. One way it doesn't provide is to ...

Discover More

Automatically Numbering Rows

Adding row numbers to a column of your worksheet is easy; you just need to use a formula to do it. Here's a quick look at ...

Discover More
##### Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. Youâ€™ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 6 - 6?

There are currently no comments for this tip. (Be the first to leave your commentâ€”just use the simple form above!)

##### This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.