Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Counting Instances

I have a column with many rows that may have blank cells in between them. how
can I get the instance or count of them?

For example in A column I have;

Q
S
Q
Q
H
H
C

Results should be;

3 Q
1 S
2 H
1 C

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200802/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Counting Instances

Since you're in the Programming group, here's a Tom Ogilvy macro.

Sub CountLetters()
''a count of each letter in a range outputted to a new sheet
Dim letCount(1 To 26) As Long
Dim wkSht As Worksheet
Dim ii As Long
Dim cell As Range
Dim WrkRng As Range
For Each wkSht In Worksheets
With wkSht
If .Name = "ListLetters" Then
Application.DisplayAlerts = False
Sheets("ListLetters").Delete
End If
End With
Next
Application.DisplayAlerts = True
Set WrkRng = ActiveSheet.UsedRange

For Each cell In WrkRng
For ii = 1 To Len(cell)
If Mid(UCase(cell), ii, 1) Like "[A-Z]" Then
letCount(Asc(Mid(UCase(cell), ii, 1)) - 64) = _
letCount(Asc(Mid(UCase(cell), ii, 1)) - 64) + 1
End If
Next ii
Next cell
Set CopytoSheet = Worksheets.Add
CopytoSheet.Name = "ListLetters"
CopytoSheet.Activate
Range("B1").Resize(26, 1).Value = Application.Transpose(letCount)
With Range("A1").Resize(26, 1)
.Formula = "=char(row()+64)"
.Value = .Value
End With

End Sub


Gord Dibben MS Excel MVP

On Sat, 01 Mar 2008 00:13:49 GMT, "saman110 via OfficeKB.com" <u35670@uwe
wrote:

I have a column with many rows that may have blank cells in between them. how
can I get the instance or count of them?

For example in A column I have;

Q
S
Q
Q
H
H
C

Results should be;

3 Q
1 S
2 H
1 C


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 419
Default Counting Instances

saman110,

Use a pivot table. Add the column to both the row area and the data area of
the pivot table. If the data area doesn't automatically select the count
function, go in and change it manully.

Look up using pivot tables in XL's Help.

HTH,

Conan




"saman110 via OfficeKB.com" <u35670@uwe wrote in message
news:807ab5487f8c3@uwe...
I have a column with many rows that may have blank cells in between them.
how
can I get the instance or count of them?

For example in A column I have;

Q
S
Q
Q
H
H
C

Results should be;

3 Q
1 S
2 H
1 C

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200802/1



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Counting Instances

My column does not always have Alphabet. It may contain words.

saman110 wrote:
I have a column with many rows that may have blank cells in between them. how
can I get the instance or count of them?

For example in A column I have;

Q
S
Q
Q
H
H
C

Results should be;

3 Q
1 S
2 H
1 C


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200803/1

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting instances in string John in Wembley Excel Discussion (Misc queries) 11 September 18th 07 06:51 PM
Counting instances of text??? tpmax Excel Worksheet Functions 7 June 27th 07 03:54 AM
Counting Multiple Instances Curtis Excel Worksheet Functions 3 January 31st 07 06:22 PM
Counting instances of an offset value??? Simon Lloyd[_621_] Excel Programming 9 June 12th 05 09:37 AM
Counting Instances of a Value? Neil[_17_] Excel Programming 2 December 5th 03 08:36 PM


All times are GMT +1. The time now is 01:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"