PC Review


Reply
Thread Tools Rate Thread

Count unique text in cell range

 
 
PhilH
Guest
Posts: n/a
 
      4th Dec 2008
In the range C5:C123, I want to count the number of times L31, L311, L316,
and L318, and blanks appear, and have the information appear like this:

L31 14
L311 24
L316 45
L318 33
Blank 3
Sum 119 (the total number of cells in the range)

How would this be done?
 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      4th Dec 2008
Hi,

You should be able to modift this for all your L numbers

="L31 = "&COUNTIF(C5:C123,"L31")

and for the blanks

="Blanks = "&COUNTBLANK(C5:C123)

Mike



"PhilH" wrote:

> In the range C5:C123, I want to count the number of times L31, L311, L316,
> and L318, and blanks appear, and have the information appear like this:
>
> L31 14
> L311 24
> L316 45
> L318 33
> Blank 3
> Sum 119 (the total number of cells in the range)
>
> How would this be done?

 
Reply With Quote
 
AndrewCerritos
Guest
Posts: n/a
 
      4th Dec 2008
Here is my take to use VBA.
Result is printed via Debug.print statement.

Private Sub CountUnique()
Dim rngA As Range
Dim varTXT As Variant
Dim varCNT() As Long
Dim iX As Long
Dim nSUM As Long

varTXT = Array("L31", "L311", "L316", "L318", "")
Set rngA = ActiveSheet.Range("C19:C123")
nSUM = 0
ReDim varCNT(LBound(varTXT) To UBound(varTXT))
For iX = LBound(varTXT) To UBound(varTXT)
varCNT(iX) = WorksheetFunction.CountIf(rngA, varTXT(iX))
If varTXT(iX) = "" Then
Debug.Print iX; "Blank", varCNT(iX)
Else
Debug.Print iX; varTXT(iX), varCNT(iX)
End If
nSUM = nSUM + varCNT(iX)
Next iX
Debug.Print "Sum", nSUM
End Sub

"Mike H" wrote:

> Hi,
>
> You should be able to modift this for all your L numbers
>
> ="L31 = "&COUNTIF(C5:C123,"L31")
>
> and for the blanks
>
> ="Blanks = "&COUNTBLANK(C5:C123)
>
> Mike
>
>
>
> "PhilH" wrote:
>
> > In the range C5:C123, I want to count the number of times L31, L311, L316,
> > and L318, and blanks appear, and have the information appear like this:
> >
> > L31 14
> > L311 24
> > L316 45
> > L318 33
> > Blank 3
> > Sum 119 (the total number of cells in the range)
> >
> > How would this be done?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula to count unique values in a range Dave K Microsoft Excel Discussion 11 22nd Mar 2008 10:39 AM
How do I count unique values within a date range? Sam Microsoft Excel Misc 5 22nd Jun 2007 06:15 AM
Count unique items in range =?Utf-8?B?VGhvbQ==?= Microsoft Excel Worksheet Functions 4 12th Oct 2006 01:13 PM
count by specific text color in range of cell Tii99 Microsoft Excel Misc 2 4th Apr 2006 09:58 AM
In Excel - How to count unique values in a range Giles Microsoft Excel Misc 1 23rd Oct 2003 02:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:36 PM.