Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default Problem using a named range

Using Excel 2003, I have a workbook with a single sheet. A single cell on
that sheet is a named range with name "bbb".

If I try to run:

Sub jnk()
Dim i As Long

i = Range(Names("bbb"))
End Sub

I get an "application defined or oblect drfined error", yet if I type
i = Range(Names("bbb"))
?i
in the immediate window, I get no error and the correct value of i is
displayed.

What is wrong with my Sub?

Thanksfor your help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 420
Default Problem using a named range

As long as BBB referred to a single cell, I'd use:

Option Explicit
Sub Junk()
dim i as long
i = activesheet.range("bbb").value
end sub

This assumes that the value is numeric, too!

On 12/24/2010 14:49, wrote:
Using Excel 2003, I have a workbook with a single sheet. A single cell on
that sheet is a named range with name "bbb".

If I try to run:

Sub jnk()
Dim i As Long

i = Range(Names("bbb"))
End Sub

I get an "application defined or oblect drfined error", yet if I type
i = Range(Names("bbb"))
?i
in the immediate window, I get no error and the correct value of i is
displayed.

What is wrong with my Sub?

Thanksfor your help.


--
Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default Problem using a named range

On Fri, 24 Dec 2010 16:48:38 -0500, GS wrote:

formulated on Friday :
Using Excel 2003, I have a workbook with a single sheet. A single cell on
that sheet is a named range with name "bbb".

If I try to run:

Sub jnk()
Dim i As Long

i = Range(Names("bbb"))
End Sub

I get an "application defined or oblect drfined error", yet if I type
i = Range(Names("bbb"))
?i
in the immediate window, I get no error and the correct value of i is
displayed.

What is wrong with my Sub?

Thanksfor your help.


Just use Range("bbb")


Thanks for your reply. I tried that and got the same result. It works in
the immediate window but not in the sub.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Problem using a named range

Just use Range("bbb")

Thanks for your reply. I tried that and got the same result. It works in
the immediate window but not in the sub.


I tried this and it worked for me!

Sub Junk()
Dim i As Long
i = Range("bbb")
Debug.Print i
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc




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
Problem copying named range IanC[_2_] Excel Programming 3 March 18th 10 03:47 PM
Find in Named Range problem (2nd Try) G.R. New Users to Excel 2 February 27th 08 08:17 PM
Named Range Problem David Excel Programming 2 May 6th 07 03:06 PM
named range problem Rbp9ad[_2_] Excel Programming 4 December 1st 05 10:21 PM
Link problem with named range Jay Northrop Excel Programming 4 August 10th 05 02:49 PM


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