#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Count


Please follow following steps
1.Right Click toolbarclick control box
2.From control box select a command button and draw it to your sheet
3.Double click the command button to open code window and paste
following codes
Private Sub CommandButton1_Click()
Dim row As Integer, col As Integer, cnt As Integer
row = 1
col = 1
cnt = 1

While Sheet1.Cells(row, col).Value < ""
cnt = chkRepeat(Sheet1.Cells(row, col).Value, row)

Sheet1.Cells(row, col + 1).Value = cnt
row = row + 1
Wend

End Sub

Private Function chkRepeat(str As String, i As Integer) As Integer
Dim tmp As Integer
tmp = 1

Dim row As Integer, col As Integer
row = 1
col = 1

While Sheet1.Cells(row, col).Value < ""
If i < row Then
If Sheet1.Cells(row, col).Value = str Then
tmp = tmp + 1
End If
End If
row = row + 1
Wend

chkRepeat = tmp
End Function

Now on clicking the button you get the number of counts listed in
column B

Have a nice time….

Chris
------
Convert your Excel spreadsheet into an online calculator.
http://www.spreadsheetconverter.com




--
Chris Bode
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
Multiple Criteria, Count If, Sum Product to get count across range Jonathan Excel Worksheet Functions 5 January 9th 08 11:32 PM
Count Employee Work Time - Don't Double-count Overlapping Apts. J Excel Worksheet Functions 0 April 27th 07 05:52 AM
Excel 2000, count, sort a list & count totals? sunslight Excel Worksheet Functions 1 April 9th 07 05:46 PM
Count Intervals of 2 Consecutive Values in same Row and Return Count across Row Sam via OfficeKB.com Excel Worksheet Functions 6 November 29th 05 03:27 PM
Count Intervals of Filtered TEXT values in Column and Return Count across a Row Sam via OfficeKB.com Excel Worksheet Functions 9 July 31st 05 03:37 AM


All times are GMT +1. The time now is 02:56 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"