grouping with vba

E

Excel_Newb

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!
 
E

Excel_Newb

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top