Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default counting blocks of data

this is a sample of a large block of data I have. A block of data is
represented by the letter A until the next cell is Blank. For E.G. row 1
has 2 blocks of data.
the 1st block is row1, col3 and 4 and the next block is column 9.
row 2 has 2 blocks. Col3,col4 and col5 is the 1st block and column 8 & 9 is
the 2nd block.
Row 3 has 1 block only. column 6&7
Row 4 has 0 blocks and row 5 has 1 block because all the A's are in adjacent
cells.

1 2 3 4 5 6 7 8 9
Row 1 A A A
Row 2 A A A A A
Row 3 A A
Row 4
Row 5 A A A A

Thank you all for your anticipated support in this again!!







I have to count each block of data per row.
E.G. Row 1 will have 2 blocks of data
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default counting blocks of data

Assuming your data is in the first 9 columns (A:I) as show, use this formula
on Row 1 to report how many "blocks" exist in Row 1 and copy the formula
down as needed...

=SUMPRODUCT((A1:H1<"")*(B1:I1=""))

--
Rick (MVP - Excel)


"tom_mcd" wrote in message
...
this is a sample of a large block of data I have. A block of data is
represented by the letter A until the next cell is Blank. For E.G. row 1
has 2 blocks of data.
the 1st block is row1, col3 and 4 and the next block is column 9.
row 2 has 2 blocks. Col3,col4 and col5 is the 1st block and column 8 & 9
is
the 2nd block.
Row 3 has 1 block only. column 6&7
Row 4 has 0 blocks and row 5 has 1 block because all the A's are in
adjacent
cells.

1 2 3 4 5 6 7 8 9
Row 1 A A A
Row 2 A A A A A
Row 3 A A
Row 4
Row 5 A A A A

Thank you all for your anticipated support in this again!!







I have to count each block of data per row.
E.G. Row 1 will have 2 blocks of data


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default counting blocks of data

This macro should do what you asked. I had to make several assumptions. I
assumed that you don't have a header row and you want to scan all columns for
all rows that have data. I also didn't know what you wanted to do with the
"blocks of data count". So I assumed you wanted to place it in a cell next
to the last column with data in your used range. Hope this helps! If so,
let me know, click "YES" below.

Sub CountBlocks()

Dim LastRow As Long
Dim LastColumn As Long
Dim rw As Long
Dim cell As Range
Dim Blocks As Long

LastRow = Sheets("Sheet1").UsedRange.Rows.Count
LastColumn = Sheets("Sheet1").UsedRange.Columns.Count

For rw = 1 To LastRow
For Each cell In Range(Cells(rw, "B"), Cells(rw, LastColumn))
If Not IsEmpty(cell) And IsEmpty(cell.Offset(, 1)) Then
Blocks = Blocks + 1
End If
Next cell
Cells(rw, LastColumn + 1).Value = Blocks
Blocks = 0
Next rw

End Sub

--
Cheers,
Ryan


"tom_mcd" wrote:

this is a sample of a large block of data I have. A block of data is
represented by the letter A until the next cell is Blank. For E.G. row 1
has 2 blocks of data.
the 1st block is row1, col3 and 4 and the next block is column 9.
row 2 has 2 blocks. Col3,col4 and col5 is the 1st block and column 8 & 9 is
the 2nd block.
Row 3 has 1 block only. column 6&7
Row 4 has 0 blocks and row 5 has 1 block because all the A's are in adjacent
cells.

1 2 3 4 5 6 7 8 9
Row 1 A A A
Row 2 A A A A A
Row 3 A A
Row 4
Row 5 A A A A

Thank you all for your anticipated support in this again!!







I have to count each block of data per row.
E.G. Row 1 will have 2 blocks of data

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 blocks of 1's Bryan De-Lara Excel Worksheet Functions 10 February 18th 08 07:11 AM
Count Blocks of Data Brendan Excel Worksheet Functions 4 January 16th 08 10:08 PM
averaging particular blocks of data robert111 Excel Discussion (Misc queries) 6 July 12th 06 02:41 PM
RangeName blocks of data CLR Excel Programming 7 March 3rd 06 05:57 PM
Copy Blocks Of Data SenojNW Excel Discussion (Misc queries) 2 August 9th 05 02:06 AM


All times are GMT +1. The time now is 10:57 PM.

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"