LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default Sequence of numbers

Hello,

I suggest to take my UDF:

Function CountStrings(r As Range) As Variant
'Returns variant with info about strings in range r:
'First row contains count of different strings and count of empty cells

'Subsequent rows show all occurring strings (sorted) and their
frequency.
'PB V0.90
Dim k As Long
Dim lidx As Long 'index of next empty field in string table
Dim l As Long
Dim rc As Range
ReDim v(0 To r.Rows.Count * r.Columns.Count, 0 To 1) As Variant '0:
string; 1: frequency


lidx = 1
For Each rc In r
If IsEmpty(rc) Then
v(0, 1) = v(0, 1) + 1
Else
'Search for current cell value in string table
v(lidx, 0) = rc 'initialize search so that value
'will be found
l = 1
Do While v(l, 0) < v(lidx, 0)
l = l + 1
Loop
If l = lidx Then
lidx = lidx + 1 'Wasn't in. Added.
Else
If v(l, 0) < rc Then
For k = lidx - 1 To l Step -1
v(k + 1, 0) = v(k, 0)
v(k + 1, 1) = v(k, 1)
Next k
v(l, 0) = rc
v(l, 1) = 0
lidx = lidx + 1
End If
End If
v(l, 1) = v(l, 1) + 1 'increase frequency
End If
Next rc
v(lidx, 0) = ""
v(0, 0) = lidx - 1
CountStrings = v
End Function

It has been designed to count strings but it will do dates, too.

Just select a two-column range in your spreadsheet and array-enter
=CountStrings(A1:A999)
(terminate with CTRL+SHIFT+ENTER)
Change A1:A999 to your desired input area.

HTH,
Bernd

 
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
sequence numbers Natalie B Excel Discussion (Misc queries) 3 October 17th 07 09:50 PM
sequence of numbers andrewm Excel Worksheet Functions 3 November 13th 05 06:20 PM
sequence numbers Ashley Excel Discussion (Misc queries) 1 July 22nd 05 02:32 PM
sequence numbers su su Excel Discussion (Misc queries) 4 May 12th 05 02:51 AM
how do I sequence numbers EL GUAPO Excel Discussion (Misc queries) 2 January 28th 05 09:45 PM


All times are GMT +1. The time now is 09:51 AM.

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

About Us

"It's about Microsoft Excel"