Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default defining a range

In the following code below, I want to copy a number of items from
Worksheet "Items" to Worksheet "Rooms" based on the value of txtRoom.

What am I doing wrong when I set "listrange" in the select statement?


I get a "Method 'range' of object '_global' error"


Thanks,


David


Worksheets("Rooms").Activate
ActiveSheet.Range("A8:A17").Select
Selection.ClearContents
Selection.Rows.RowHeight = 36


Worksheets("Items").Activate
Set itemrange = Worksheets("Items").Range("a1",
Range("a1").End(xlToRight))
For Each ir In itemrange
If ir.Text = txtRoom Then
Exit For
End If
Next ir
Worksheets("Items").Activate
Select Case txtRoom


Case "Room1"


Set listrange = Worksheets("Items").Range(ir, Range(ir).End(xlDown))
listrange.Copy Destination:=Worksheets("SF 701").Range("a8")


Case "Room2"
....


Case "Room3"
....


Case "Room4"
....


End Select

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default defining a range

ir is a range. The default property is it's value so what you have is the
same as

Set listrange = Worksheets("Items").Range(ir, Range(ir.Value).End(xlDown))
and the value of ir is the contents of the first cell in the range.

try this...

Set listrange = Worksheets("Items").Range(ir, ir.End(xlDown))

if you have decalred ir as a range then you will get the intellisence list
of properties and methods for ir.
Dim ir as Range

--
HTH...

Jim Thomlinson


" wrote:

In the following code below, I want to copy a number of items from
Worksheet "Items" to Worksheet "Rooms" based on the value of txtRoom.

What am I doing wrong when I set "listrange" in the select statement?


I get a "Method 'range' of object '_global' error"


Thanks,


David


Worksheets("Rooms").Activate
ActiveSheet.Range("A8:A17").Select
Selection.ClearContents
Selection.Rows.RowHeight = 36


Worksheets("Items").Activate
Set itemrange = Worksheets("Items").Range("a1",
Range("a1").End(xlToRight))
For Each ir In itemrange
If ir.Text = txtRoom Then
Exit For
End If
Next ir
Worksheets("Items").Activate
Select Case txtRoom


Case "Room1"


Set listrange = Worksheets("Items").Range(ir, Range(ir).End(xlDown))
listrange.Copy Destination:=Worksheets("SF 701").Range("a8")


Case "Room2"
....


Case "Room3"
....


Case "Room4"
....


End Select


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default defining a range

Thank you very much. That did the trick.

David

On Mar 17, 6:56*pm, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com wrote:
ir is a range. The default property is it's value so what you have is the
same as

Set listrange = Worksheets("Items").Range(ir, Range(ir.Value).End(xlDown))
and the value of ir is the contents of the first cell in the range.

try this...

Set listrange = Worksheets("Items").Range(ir, ir.End(xlDown))

if you have decalred ir as a range then you will get the intellisence list
of properties and methods for ir.
Dim ir as Range

--
HTH...

Jim Thomlinson

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
Defining Range Name anshu[_2_] Excel Discussion (Misc queries) 2 July 22nd 07 07:30 AM
Defining a range in vba???? Please help Need Help Fast![_2_] Excel Programming 2 March 19th 07 07:55 PM
Defining series range for named range Barb Reinhardt Excel Programming 1 August 3rd 06 09:00 PM
Defining a range Jonathan Excel Programming 3 June 28th 06 06:11 AM
Defining a range and use it's value Petitboeuf[_3_] Excel Programming 1 December 15th 05 06:34 PM


All times are GMT +1. The time now is 09:13 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"