Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dyl Dyl is offline
external usenet poster
 
Posts: 10
Default Range - Application Defined or Object Defined Error

Hello,

I am having a problem with declaring a range object. The code which I
receive the Application/Object Defined error for is

Set myRange2 =
ThisWorkbook.Worksheets("Procedures").Range(Cells( TotalNames + 3, 1),
Cells(TotalNames + 3, 2))

I am frustrated because I have a line of code in my program which does
work and is almost identical.

Set myRange = ThisWorkbook.Worksheets("Procedures").Range(Cells( 2,
NumberofBuilds + 2), Cells(3, NumberofBuilds + 2))



I am unclear of how to use Range syntax, but I am comfortable referring
to cells using cell index numbers. Any help or reccomendations would
be appreciated.

Thanks for your time.

Dylan H

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Range - Application Defined or Object Defined Error

Should work, but what is the value of TotalNames?
Note that if your calculated range goes beyond the row/column limitations of
an Excel spreadsheet it will be unable to evaluate the range and you will get
the error you describe. Limits are 65,536 rows by 256 columns. So if
TotalNames is, say, 65535 then Cells(TotalNames + 3, 1) is out of bounds.
--
- K Dales


"Dyl" wrote:

Hello,

I am having a problem with declaring a range object. The code which I
receive the Application/Object Defined error for is

Set myRange2 =
ThisWorkbook.Worksheets("Procedures").Range(Cells( TotalNames + 3, 1),
Cells(TotalNames + 3, 2))

I am frustrated because I have a line of code in my program which does
work and is almost identical.

Set myRange = ThisWorkbook.Worksheets("Procedures").Range(Cells( 2,
NumberofBuilds + 2), Cells(3, NumberofBuilds + 2))



I am unclear of how to use Range syntax, but I am comfortable referring
to cells using cell index numbers. Any help or reccomendations would
be appreciated.

Thanks for your time.

Dylan H


  #3   Report Post  
Posted to microsoft.public.excel.programming
Dyl Dyl is offline
external usenet poster
 
Posts: 10
Default Range - Application Defined or Object Defined Error

Hi K,

The value of TotalNames is 1 when error occurs.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Range - Application Defined or Object Defined Error


Hello Dylan,

You probably forgot to dimesion Range2 as either an Object type or
Range type.
Check that in your Sub or Function that there is a line like either of
the 2 shown...

Dim Range2 As Object
Dim Range2 As Range

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=480632

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Range - Application Defined or Object Defined Error

It could be a problem with the resolution of cells. You do not specify the
worksheet when you make the reference. Try something like this...

with ThisWorkbook.Worksheets("Procedures").
Set myRange2 = .Range(.Cells(TotalNames + 3, 1), .Cells(TotalNames + 3, 2))
end with

--
HTH...

Jim Thomlinson


"Dyl" wrote:

Hello,

I am having a problem with declaring a range object. The code which I
receive the Application/Object Defined error for is

Set myRange2 =
ThisWorkbook.Worksheets("Procedures").Range(Cells( TotalNames + 3, 1),
Cells(TotalNames + 3, 2))

I am frustrated because I have a line of code in my program which does
work and is almost identical.

Set myRange = ThisWorkbook.Worksheets("Procedures").Range(Cells( 2,
NumberofBuilds + 2), Cells(3, NumberofBuilds + 2))



I am unclear of how to use Range syntax, but I am comfortable referring
to cells using cell index numbers. Any help or reccomendations would
be appreciated.

Thanks for your time.

Dylan H




  #6   Report Post  
Posted to microsoft.public.excel.programming
Dyl Dyl is offline
external usenet poster
 
Posts: 10
Default Range - Application Defined or Object Defined Error

Thanks Jim. That did it.

Thanks for your help Leith and K and Jim!

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Range - Application Defined or Object Defined Error

Just for reference Cells would have been looking at the acitve sheet
(whatever that might be). Unless otherwise specified that is where it looks.
--
HTH...

Jim Thomlinson


"Dyl" wrote:

Thanks Jim. That did it.

Thanks for your help Leith and K and Jim!


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
Run-time error '50290': Application-defined or object-defined erro Macro button Excel Discussion (Misc queries) 1 March 12th 09 10:59 AM
Application-Defined or Object-Defined Error on simple code Fid[_2_] Excel Programming 1 July 21st 05 08:30 PM
error: ActiveCell.Offset(0, -1).Select = Application-defined or object-defined error -[::::Shamran::::]- Excel Programming 7 June 7th 05 02:14 PM
Application-Defined or Object-Defined Error on simple code [email protected] Excel Programming 6 February 22nd 05 09:03 PM
Application-defined or object-defined error - missing the basics [email protected] Excel Programming 1 December 28th 04 10:23 PM


All times are GMT +1. The time now is 01:46 AM.

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"