Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default Setting range by cells fails

On Feb 12, 8:32*pm, Charabeuh wrote:
Hello,

Cells refers to the active sheet. If your active sheet is not
worksheet("test"), an error will occur.

Try this:

With Worksheets("test")
* Set RNG = Range(.Cells(1, 1), .Cells(1, 1))
End With

OR

Set RNG = Range(Worksheets("test").Cells(1, 1), _
* * Worksheets("test").Cells(3, 3))

Andrew a écrit :

Hello,
I have been trying to set a range using the following code:


Dim RNG as Range
Set RNG = worksheets("test").Range(cells(1,1),cells(10,10))


This fails with an error 1004


but if I use this code
Dim RNG as Range
Set RNG = worksheets("test").Range("A1:J10)


The code works.


This is the same range, why won't the compiler accept the first code?


thanks,
andy


Thanks for the help. It seems that "Set RNG =
worksheets("test").Range(cells(1,1),cells(10,10))"
would default to the cells on the worksheet "test". I'll have to
experiment with this to see what makes it fail.

thanks
Andy
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
Setting Curline to 0 on a text box fails (Excel 2007) Andrew B Excel Programming 3 August 30th 09 09:15 AM
Setting up formatting for a range of cells [email protected] Excel Discussion (Misc queries) 0 January 4th 07 04:17 PM
Setting an array range of cells??? Simon Lloyd[_773_] Excel Programming 2 June 16th 06 03:30 AM
Setting OnAction Property Fails Josh Sale Excel Programming 13 August 31st 05 09:02 PM
Setting CommandText property of PivotCache fails if cache has 1 PivotTable ashortxl Excel Programming 1 May 20th 05 10:27 PM


All times are GMT +1. The time now is 06:57 PM.

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

About Us

"It's about Microsoft Excel"