Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Trapper via OfficeKB.com
 
Posts: n/a
Default Count Consecutive Cells

I have a simple need: I have one column of data containing either an O or
a U. Is there a way I can ask EXCEL to tell me how many times the O
appeared in 2 consecutive cells, 3 consecutive cells... etc. Say I am
using collumn A for this
A
1 O
2 O
3 O
4 U
5 U
6 O
7 U
8 U
9 U
10 U
  #2   Report Post  
Domenic
 
Posts: n/a
Default

Try the following...

B1, copied down:

=SUM(--(COUNTIF(OFFSET($A$1:$A$10,ROW($A$1:$A$10)-MIN(ROW($A$1:$A$10)),0,
ROWS($B$1:B1)+1),"O")=ROWS($B$1:B1)+1))

....confirmed with CONTROL+SHIFT+ENTER, not just ENTER. Note that the
result displayed in B1 will tell you how many times 'O' appeared in 2
consecutive cells, B2 will tell you how many times 'O' appeared in 3
consecutive cells, and so on.

Hope this helps!

In article ,
"Trapper via OfficeKB.com" wrote:

I have a simple need: I have one column of data containing either an O or
a U. Is there a way I can ask EXCEL to tell me how many times the O
appeared in 2 consecutive cells, 3 consecutive cells... etc. Say I am
using collumn A for this
A
1 O
2 O
3 O
4 U
5 U
6 O
7 U
8 U
9 U
10 U

  #3   Report Post  
Duke Carey
 
Posts: n/a
Default

Please post your question in only one newsgroup. See the responses in
Worksheet Functions

"Trapper via OfficeKB.com" wrote:

I have a simple need: I have one column of data containing either an O or
a U. Is there a way I can ask EXCEL to tell me how many times the O
appeared in 2 consecutive cells, 3 consecutive cells... etc. Say I am
using collumn A for this
A
1 O
2 O
3 O
4 U
5 U
6 O
7 U
8 U
9 U
10 U

  #4   Report Post  
Trapper via OfficeKB.com
 
Posts: n/a
Default

thanks a bunch I will check it out! Sorry for the double posting.. I was
asking 2 questions in the same link and wanted to break it out!

--
Message posted via http://www.officekb.com
  #5   Report Post  
Bob Phillips
 
Posts: n/a
Default

=COUNTIF($A$1:$A$1000,D1)-SUMPRODUCT(--($A$1:$A$999=D1),--($A$1:$A$999<$A$2
:$A$1000),--($A$2:$A$1000=$A$3:$A$1001))

where D1 holds the letter to test

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Trapper via OfficeKB.com" wrote in message
...
I have a simple need: I have one column of data containing either an O or
a U. Is there a way I can ask EXCEL to tell me how many times the O
appeared in 2 consecutive cells, 3 consecutive cells... etc. Say I am
using collumn A for this
A
1 O
2 O
3 O
4 U
5 U
6 O
7 U
8 U
9 U
10 U





  #6   Report Post  
craig trapp via OfficeKB.com
 
Posts: n/a
Default

ok both of these formulas work, thanks for the help! BUT I have a small
problem... the worksheet that I am trying to use these on was copied from a
table on a web page into EXCEL. The formula is not working on the column
of data that was copied from the web-page, BUT it does work when I enter my
own data. Is the format weird because of the web page it came from?
Anyone know? I tried highlighting the column and formatting as text to no
avail!

--
Message posted via http://www.officekb.com
  #7   Report Post  
Gord Dibben
 
Posts: n/a
Default

Craig

Web Pages leave all kinds of crap in the cells.

Try David McRitchie's TRIMALL macro on your data.

Sub TrimALL()
'David McRitchie 2000-07-03 mod 2000-08-16 join.htm
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim Cell As Range
'Also Treat CHR 0160, as a space (CHR 032)
Selection.Replace What:=Chr(160), Replacement:=Chr(32), _
Lookat:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
'Trim in Excel removes extra internal spaces, VBA does not
On Error Resume Next 'in case no text cells in selection
For Each Cell In Intersect(Selection, _
Selection.SpecialCells(xlConstants, xlTextValues))
Cell.Value = Application.Trim(Cell.Value)
Next Cell
On Error GoTo 0
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub


Gord Dibben Excel MVP

On Mon, 23 May 2005 22:38:59 GMT, "craig trapp via OfficeKB.com"
wrote:

ok both of these formulas work, thanks for the help! BUT I have a small
problem... the worksheet that I am trying to use these on was copied from a
table on a web page into EXCEL. The formula is not working on the column
of data that was copied from the web-page, BUT it does work when I enter my
own data. Is the format weird because of the web page it came from?
Anyone know? I tried highlighting the column and formatting as text to no
avail!


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
Count Position of Filtered TEXT cells in a column Sam via OfficeKB.com Excel Worksheet Functions 8 May 18th 05 04:23 AM
Count Position of Filtered TEXT cells in a column Sam via OfficeKB.com Excel Worksheet Functions 0 May 15th 05 08:14 PM
COUNT NON-BLANK CELLS WITH REFERENCE TO ANOTHER COLUMN carricka Excel Worksheet Functions 1 May 6th 05 04:50 PM
Can I count how many grey-filled cells are in a row ? AnthonyG Excel Worksheet Functions 1 February 4th 05 10:08 AM
Count number of shaded cells Maddoktor Excel Discussion (Misc queries) 2 December 20th 04 08:35 PM


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