Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Tom,
Apologies, no need for my amendment to ElseIf ar.Count = 5 Then cnt1 = cnt1 + 2 I should have used your first version of the code and not the version headed up "this matches your results". Cheers, Sam Tom Ogilvy wrote: Sub CountData() Dim rng As Range, rng1 As Range Dim cnt As Range, cell As Range Dim cell1 As Range, cnt1 As Long Set rng = Range("Data") Set rng1 = Range(Cells(2, 1), Cells(2, 1).End(xlDown)) For Each cell In rng1 Set rng2 = Nothing For Each cell1 In rng If cell1 = cell Then If rng2 Is Nothing Then Set rng2 = Cells(cell1.Row, 1) Else Set rng2 = Union(rng2, Cells(cell1.Row, 1)) End If End If Next cnt1 = 0 For Each ar In rng2.Areas If ar.Count = 2 Then cnt1 = cnt1 + 1 End If Next cell.Offset(0, 1).Value = cnt1 Next End Sub Produces results matching yours except for 129. 29 is correct per your VBA code. My count was incorrect. -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200702/1 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Count x2 Appearance of Numeric Value in any Row | Excel Worksheet Functions | |||
Exclude #N/A values and Return Numeric values to consecutive cells in Single Row | Excel Worksheet Functions | |||
Count & Sum Consecutive (2x) appearance of Specific Numeric Values | Excel Worksheet Functions | |||
Return Summed Count of Multiple Consecutive Numeric Values | Excel Worksheet Functions | |||
Count Intervals of 2 Consecutive Values in same Row and Return Count across Row | Excel Worksheet Functions |