Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 200
Default Set Range error

Die_Another_Day wrote:
Because Cells, unless otherwise told, references cells on the
ActiveSheet. So you are tell it in effect:
Set fromRange = Worksheets("AAdata").Range(ActiveSheet.Cells(2, 4), _
ActiveSheet.Cells(2, 11))
What you really want to tell it is this:
Set fromRange =
Worksheets("AAdata").Range(Worksheets("AAdata").Ce lls(2, 4), _
Worksheets("AAdata").Cells(2, 11))
Which could be shortened to this:
With Sheets("AAdata")
Set fromRange = .Range(.Cells(2,4),.Cells(2,11))
End With


Or shortened further to

Set rng = Sheets("AAdata").Range("A1")
Set fromRange = Range(rng(2, 4), rng(2, 11))

Alan Beban
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
Runtime Error - Subscript out of range despite On Error statement DoctorG Excel Programming 3 July 28th 06 03:56 PM
Subscript out of range error - save copy error bg18461[_16_] Excel Programming 2 June 13th 06 04:53 PM
Subscript out of range error - save copy error bg18461[_15_] Excel Programming 1 June 13th 06 04:36 PM
Range.Select error and screen maximizing error in Workbook_Open() Punsterr Excel Programming 3 May 10th 06 10:16 PM
Range.Select error and screen maximizing error in Workbook_Open() Punsterr Excel Programming 0 May 10th 06 07:56 PM


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