Michael
Michael

Reputation: 93

How to group rows in vba?

After I have decided a starting row and an ending row earlier on in my code, I am having trouble grouping all of the rows between the start and end. Both my start_row and end_row variables are Integers.

(start_row and end_row are the variables, wS is my worksheet) A few of the things I have already tried:

- wS.Rows("start_row" & ":" & "end_row").Group
- wS.Rows("5:6").Group '(just did this to test)

I either get a type mismatch or application defined error. I believe my syntax for grouping is wrong, so if someone could help that would be so helpful. Thanks

Upvotes: 0

Views: 1876

Answers (2)

QuickSilver
QuickSilver

Reputation: 770

You need to do something like this.

wS.Rows(start_row & ":" & end_row).Group
wS.Rows("5:6").Group

Upvotes: 1

Skin
Skin

Reputation: 11197

wS.Rows(start_row & ":" & end_row).Group

Upvotes: 2

Related Questions