?
Solved

Problem with counting

Posted on 2013-12-14
10
Medium Priority
?
229 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 97

Expert Comment

by:Experienced Member
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 97

Expert Comment

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

.... Thinkpads_User
0
Independent Software Vendors: 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

777 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