Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Different usage of range formats, conflict?


Hi all,
I've got confused with many range formats. In Help site of MS Office
2003 told that these 2 types of range is the same:
ex1: Range("A1:C20")
ex2: Range(cells(1,1),cells(20,3))
However I've found that they are different in using.
ex1: sheets(1).Range("A1:C20").copy(sheets(2).range("A1 ")) -- It's
working
ex2:
sheets(1).Range(cells(1,1),cells(20,3)).copy(sheet s(2).range("A1")) --
fail
Object-defined error????
I really dont know what is the different thing here? The same case with
others functions using with range?
Anybody meet the same problem like me? plz give me some hints or show
me the solving? thanks a lots!!!


--
azzura
------------------------------------------------------------------------
azzura's Profile: http://www.excelforum.com/member.php...o&userid=37450
View this thread: http://www.excelforum.com/showthread...hreadid=571156

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Different usage of range formats, conflict?

Whenever Cells(1,1) is not prefixed with a dot it refers to a cell on the
activesheet, unless the code is in a sheet module in which case it refers to
that sheet (typically but not necessarily the active sheet).

sheets(1).Range(cells(1,1),cells(20,3))

will only work if Sheets(1) is the active worksheet

Instead try

Worksheets(1).Range(Worksheets(1).Cells(1,1), Worksheets(1)..Cells(20,3))

or

With Worksheets(1)
.Range(.Cells(1,1), .Cells(20,3)) etc
End With

Note the dot prefix .Cells(

Alternatively
Worksheets(1).Range("A1:C" & 20)

In passing note Sheets(1) in this context would fail if a chart sheet

Regards,
Peter T


"azzura" wrote in
message ...

Hi all,
I've got confused with many range formats. In Help site of MS Office
2003 told that these 2 types of range is the same:
ex1: Range("A1:C20")
ex2: Range(cells(1,1),cells(20,3))
However I've found that they are different in using.
ex1: sheets(1).Range("A1:C20").copy(sheets(2).range("A1 ")) -- It's
working
ex2:
sheets(1).Range(cells(1,1),cells(20,3)).copy(sheet s(2).range("A1")) --
fail
Object-defined error????
I really dont know what is the different thing here? The same case with
others functions using with range?
Anybody meet the same problem like me? plz give me some hints or show
me the solving? thanks a lots!!!


--
azzura
------------------------------------------------------------------------
azzura's Profile:

http://www.excelforum.com/member.php...o&userid=37450
View this thread: http://www.excelforum.com/showthread...hreadid=571156



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Different usage of range formats, conflict?


Yeah, thanks Peter.
It works well. It's just a little hint but help m

--
azzur
-----------------------------------------------------------------------
azzura's Profile: http://www.excelforum.com/member.php...fo&userid=3745
View this thread: http://www.excelforum.com/showthread.php?threadid=57115

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
range usage question jzingman Excel Worksheet Functions 6 January 10th 08 04:45 PM
Conflict with valid range reference error smaruzzi Excel Discussion (Misc queries) 1 March 14th 07 10:05 PM
Name Range & Macro conflict John Excel Discussion (Misc queries) 3 July 3rd 06 06:07 PM
Dynamic range not resized for RowSource usage Tim Zych[_8_] Excel Programming 3 August 9th 04 02:08 AM
Variable usage in Range Command DavidC[_2_] Excel Programming 2 May 27th 04 03:51 AM


All times are GMT +1. The time now is 02:35 AM.

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"