Solved

Count Total Data

Posted on 2011-03-01
10
202 Views
Last Modified: 2012-06-27
Hi Experts,

I would like to request Experts help. How to count number of data that were displayed at Column C automatically at cell E3 when search result displayed at SearchData. Hope Experts could help me to create this feature. I have attached the workbook with sample data for Experts to get better view.



CountTotal.xls
0
Comment
Question by:Cartillo
[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
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 33

Assisted Solution

by:jppinto
jppinto earned 100 total points
ID: 35005780
Put this on cell E3:

=COUNTA(B5:B)

0
 
LVL 33

Expert Comment

by:jppinto
ID: 35005785
Let's see if I understand your question. You just want to count how many "types" appear on column B of sheet SearchData and put the value on cell E3, right?

jppinto
0
 
LVL 50

Accepted Solution

by:
Ingeborg Hawighorst (Microsoft MVP / EE MVE) earned 300 total points
ID: 35005802
@jppinto, when I run this, I get a 1 as a result. Did you test that?

Cartillo,

maybe something like this:

=COUNTIF(B:B,"*"&E2&"*")

cheers, teylyn
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 2

Assisted Solution

by:s___k
s___k earned 100 total points
ID: 35005843
Try this

Dim row, col, counter As Integer
Dim searchstr As String
searchstr = Sheet1.Cells(2, 5)

col = 2
row = 5
counter = 0

While Sheet1.Cells(row, col) <> ""

    If InStr(CStr(Sheet1.Cells(row, col)), searchstr) > 0 Then
        counter = counter + 1
    End If
    row = row + 1
Wend

Sheet1.Cells(3, 5) = counter
0
 
LVL 50
ID: 35005881
@s___k,

there is absolutely no need to use VBA if the same can be accomplished with a formula. A native Excel formula will always be way faster than VBA, especially when the code loops through a range.

The formula I suggested does exactly the same as your code, but more efficiently. Even if the brief was to use VBA (which it isn't), it would be more efficient to use a Worksheet Function statement instead of looping through all populated cells in column B.

cheers, teylyn
0
 
LVL 33

Expert Comment

by:jppinto
ID: 35005988
teylyn, I've tested when I only had one "type" on column B, so I was getting 1 on cell E3. When I've tested now with more results, I still got 1 :) So the formula could be changed to:

=COUNTA(B:B)-1

This way it works.

jppinto
0
 
LVL 50
ID: 35006025
The way I read the question is that E3 should display a count of all cells in column B that contain the text string in E2.

My suggestion does that.

jppinto's suggestion will count all text cells in column B minus one, regardless of their content.

Cartillo, please explain the requirements in a bit more detail.

cheers, teylyn
0
 
LVL 33

Expert Comment

by:jppinto
ID: 35006188
That's why I asked the author to explain what he wants. Either mine works for what he wants, or teylyn's formula works if he wants another thing...Let's wait to see what the author has to say.

jppinto
0
 

Author Comment

by:Cartillo
ID: 35008835
Hi jppinto,teylyn & s___k,

Thanks for the help. Teylyn's solution works for me.

0
 

Author Closing Comment

by:Cartillo
ID: 35008858
Hi,

Thanks for the help
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
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…

728 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