Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi K,
The value of TotalNames is 1 when error occurs. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Jim. That did it.
Thanks for your help Leith and K and Jim! |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Run-time error '50290': Application-defined or object-defined erro | Excel Discussion (Misc queries) | |||
Application-Defined or Object-Defined Error on simple code | Excel Programming | |||
error: ActiveCell.Offset(0, -1).Select = Application-defined or object-defined error | Excel Programming | |||
Application-Defined or Object-Defined Error on simple code | Excel Programming | |||
Application-defined or object-defined error - missing the basics | Excel Programming |