Selecting multiple rows using two variables for the row numbers.


Posted by Brian Amoroso on April 10, 2001 5:49 PM

I already have two different row numbers in two different viariables, now I want
to do is highlight the region inbetween these two row numbers and hide them.
Here's the code I'm trying but it doesn't work.

The two variables (ABCBegin, ABCEnd) are defined as integers.
Why doesn't this code select these rows???


With ActiveSheet
.Rows("ABCBegin, ABCEnd").Select
Selection.EntireRow.Hidden = True
End With


Please help!!!!

Thank You.

Posted by anon on April 10, 2001 6:00 PM

Rows(ABCBegin & ":" & ABCEnd).EntireRow.Hidden = True


Posted by Dave Hawley on April 10, 2001 8:21 PM

Hi Brian

anon, has given the answer, the only bits I will add are that.

1. Not need for ActiveSheet and the default is always the ActiveSheet. As seen in anons code.

2. Unless certain I always dimension row varaibles as Long as there are 65536 rows.


Dave

OzGrid Business Applications



Posted by brian on April 11, 2001 8:28 AM

Thanks!!! It works!

Thanks so much to both of you. I tried it this morning and it worked. I really appreciate it.

The variables were dimensioned at the top of this submodule, an ex is:

Dim ABCEnd as Integer

Is this what you were talking about?

I'll leave out the With ActiveSheet also. As you can prob tell I'm a bit new to VB here!

Thanks again.

Brian