selecting rows using a variable

B

bigjim

I am using excel 2003 and I need to select rows using a variable. Here is
what I have now:

Dim name As String
name = Range("e800")

ActiveWorkbook.Sheets("individual stats").Range("a1:a1540").Select
Selection.EntireRow.Hidden = True

Dim Start As Integer
Dim finish As Integer

Start = Application.WorksheetFunction.Lookup(name, Range("Q800:Q881"),
Range("t800:t881"))
finish = Application.WorksheetFunction.Lookup(name, Range("Q800:Q881"),
Range("u800:u881"))

ActiveWorkbook.Sheets("individual stats").Rows(Start, finish).Select


Selection.EntireRow.Hidden = False

I verifed that in the case I was testing, start = 81 and finish = 100. With
this code I get "Application-defined or object-defined error" with the row
selection line highlighted.

any help would be appreciated
 
M

Mike H

Hi,

Note your variables now declared as LONG and that we are no longer selecting
anything

Dim name As String
Dim Start As Long
Dim finish As Long
name = Range("e800").Value
ActiveWorkbook.Sheets("individual stats").Rows(1).EntireRow.Hidden = True
Start = Application.WorksheetFunction.Lookup(name, _
Range("Q800:Q881"), Range("t800:t881"))
finish = Application.WorksheetFunction.Lookup(name, _
Range("Q800:Q881"), Range("u800:u881"))
ActiveWorkbook.Sheets("individual stats").Rows(Start & ":" & _
finish).EntireRow.Hidden = False


--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
M

Mike H

Glad i could help and thanks for the feedback
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 

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