Archive of Mr Excel Message Board


Back to Excel VBA archive index
Back to archive home





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.


Check out our Excel VBA Resources

Re: Selecting multiple rows using two variables for the row numbers.

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

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



Re: Selecting multiple rows using two variables for the row numbers.

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


Thanks!!! It works!

Posted by brian on April 11, 2001 8:28 AM
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




This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.