Grouping Rows

A

Ayo

I need to group a bunch of rows but I am having some problems. The code
lines below works great:
Rows("5:8").Select
Selection.Rows.Group
but I need to group these rows 12,14,16,18,20,22,24,26,28,30. I tried
Rows("12,14,16,18,20,22,24,26,28,30").Select
Selection.Rows.Group
but I get and Overflow error message. When I tried
Me.Rows("12:12,14:14,16:16,18:18,20:20,22:22,24:24,26:26,28:28,30:30").Select
Selection.Rows.Group
I get a Type mismatch error message.

What am I doing wrong?
 
P

Per Jessen

HI

The 'Rows' object obviously do not accept non-coherent rows, but the Range
object does, so the code below will work:

Range("A12,A14,A16,A18,A20,A22,A24,A26,A28,A30").EntireRow.Select

Regards,
Per
 

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