#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default grouping with vba

I have loaded a range (for example: A1:B5000):

Set staticRng = Range("A1:B1208")

I need to Group based on Len() 3. For example, if cell A1 has 2
characters, then A2 - A4 has 3 characters group them (A2 - A4) together. Cell
A5 might then only have two characters, and then A6 - A10 might have four
characters - which should be grouped together (A6 - A10).

(just an example, lengths will always differ)
A1 - not grouped

A2A --|
A3A --| grouped
A4A --|

A5 - not grouped

A6 --|
A7 --|
A8 --| grouped
A9 --|
A10 -|

So basically, anything with a character length 3 group together with all
other contiguous cells, until the chracter length changes.

pseudocode:

If the character length 3
Yes: Group with all contiguous rows that contain the same length
No: Do not group

I know you can group a static range using the "selection.rows.group" method.
However, I'm not sure how to keep track of the range (contiguous rows with
the same character length in "A") while cycling through the For Loop.

Any help is appreciated!









  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default grouping with vba

Disregard......Using a for loop and the rows.group method, I was able to get
this working. (Thanks, Dave P.)


"Excel_Newb" wrote:

I have loaded a range (for example: A1:B5000):

Set staticRng = Range("A1:B1208")

I need to Group based on Len() 3. For example, if cell A1 has 2
characters, then A2 - A4 has 3 characters group them (A2 - A4) together. Cell
A5 might then only have two characters, and then A6 - A10 might have four
characters - which should be grouped together (A6 - A10).

(just an example, lengths will always differ)
A1 - not grouped

A2A --|
A3A --| grouped
A4A --|

A5 - not grouped

A6 --|
A7 --|
A8 --| grouped
A9 --|
A10 -|

So basically, anything with a character length 3 group together with all
other contiguous cells, until the chracter length changes.

pseudocode:

If the character length 3
Yes: Group with all contiguous rows that contain the same length
No: Do not group

I know you can group a static range using the "selection.rows.group" method.
However, I'm not sure how to keep track of the range (contiguous rows with
the same character length in "A") while cycling through the For Loop.

Any help is appreciated!









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
To sum by grouping Dan Excel Discussion (Misc queries) 1 January 15th 09 01:51 AM
grouping MINAL ZUNKE New Users to Excel 4 June 29th 05 04:36 PM
Grouping Kevin M Excel Worksheet Functions 1 June 10th 05 11:11 PM
Grouping Ray Excel Discussion (Misc queries) 0 March 2nd 05 04:51 PM
Grouping Lila Excel Discussion (Misc queries) 1 March 1st 05 03:33 AM


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