Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default selecting rows using a variable

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default selecting rows using a variable

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.


"bigjim" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default selecting rows using a variable

That did it. Thanks, I really appreciate it.

Jim

"Mike H" wrote:

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.


"bigjim" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default selecting rows using a variable

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.


"bigjim" wrote:

That did it. Thanks, I really appreciate it.

Jim

"Mike H" wrote:

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.


"bigjim" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
selecting rows using a variable. cherrynich Excel Programming 2 May 2nd 06 08:27 PM
selecting variable rows in a macro that creates a pivot table amarch00 Excel Programming 1 May 12th 05 03:43 PM
selecting range of cells - variable # of rows [email protected] Excel Programming 6 April 15th 05 02:10 PM
Selecting Variable Rows Matt D. Excel Programming 3 June 18th 04 07:22 PM
Selecting rows with variable Jim[_24_] Excel Programming 7 September 16th 03 02:03 PM


All times are GMT +1. The time now is 10:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"