Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem with counting

Posted on 2013-12-14
10
Medium Priority
?
237 Views
Last Modified: 2013-12-15
Folks,
In Column A of the attached workbook I have various IP addresses, some with one to three "xxx". In D3:D5 I have an array formula using SUM, MID, COLUMN functions.

I'm not getting the expected results. I am wanting to know how many IP address's have one "x", two, "xx" and three "xxx". I get the three "xxx" but that all.
COUNT.xlsm
0
Comment
Question by:Frank Freese
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
10 Comments
 
LVL 98

Expert Comment

by:John Hurst
ID: 39719372
The cells are formatted as General. Try formatting the cells you are test as Text.  I think they need to be formatted as Text for MID, LEFT and RIGHT to work.

... Thinkpads_User
0
 

Author Comment

by:Frank Freese
ID: 39719379
I changed the formatting to text but the results were the same.
By the way I am not using RIGHT but I am using COLUMN
0
 
LVL 98

Expert Comment

by:John Hurst
ID: 39719419
I don't know. You are using Array formulas and I have not used these.

.... Thinkpads_User
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Frank Freese
ID: 39719425
Thanks for the time. Let's see what other's will say.
0
 
LVL 81

Accepted Solution

by:
byundt earned 2000 total points
ID: 39719459
Why not use COUNTIF with wildcards?

=COUNTIF(A:A,"*xxx*")           count of cells containing xxx
=COUNTIF(A:A,"*xx*") - K2     count of cells containing xx     (K2 is count above)
=COUNTIF(A:A,"*x*") -SUM(K2:K3)       count of cells containing x   (K2 & K3 are counts above)
COUNT-Q28318483.xlsm
0
 
LVL 81

Assisted Solution

by:byundt
byundt earned 2000 total points
ID: 39719463
Thinkpads_User,
If you change the format of a cell, it does not change the contents of that cell. If they were originally numbers, changing the format to text does not make those cells contain text. And vice-versa.

The array formulas were double or triple counting cells when looking for "xx" or "x". This is because they were getting substrings from the cell starting at each possible position. So a cell containing "xxx" would trigger two "xx" counts--one for the first two x and the second for the last two.

Similarly, a count for "x" would be triggered three times in a cell containing "xxx" and twice in one containing "xx".

COUNTIF only counts a cell once, no matter how many times the pattern is matched. What's more, you don't need to array-enter the formula.

Brad
0
 

Author Comment

by:Frank Freese
ID: 39719471
Brad,
Thanks for the explanation. Why didn't I use COUNTIF? Let's just say I had another senior moment and then I wanted to experiment more with using arrays.
Great solution - great job!
0
 

Author Closing Comment

by:Frank Freese
ID: 39719472
Thank you very much - I really appreciate it!
0
 
LVL 81

Expert Comment

by:byundt
ID: 39719489
fh_freese,
If you really want to use an array formula, consider one like this to find the number of cells containing "x" (but not "xx" or "xxx"):
=SUM(ISNUMBER(SEARCH("x",A2:A11)) - ISNUMBER(SEARCH("xx",A2:A11)))

Brad
0
 

Author Comment

by:Frank Freese
ID: 39720189
Brad,
Thanks for the extra tip!
Frank
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question