Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Range Name issue

I have created a named range with a single value in it and I can't seem to
access it within my VBA code. This is what I have so far. I've put it in
a debug.print statement to see if I can see what's going on and it gacks each
time.

Debug.Print Range("P_bar").Text
Debug.Print Range("P_bar").Value

I get a

Runtime error '1004'
Method 'range' of object '_Global' failed.

I can access the named range from the worksheet, just not the macro. The
named range is a workbook range, not a worksheet range.

Thanks,

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Range Name issue

The range name definition is

=SUM(Defectives)/SUM(Opportunities)

If that helps at all.

"Barb Reinhardt" wrote:

I have created a named range with a single value in it and I can't seem to
access it within my VBA code. This is what I have so far. I've put it in
a debug.print statement to see if I can see what's going on and it gacks each
time.

Debug.Print Range("P_bar").Text
Debug.Print Range("P_bar").Value

I get a

Runtime error '1004'
Method 'range' of object '_Global' failed.

I can access the named range from the worksheet, just not the macro. The
named range is a workbook range, not a worksheet range.

Thanks,

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Range Name issue

to access a named range w/code use the following:

for accessing on an active sheet
Range("MyRange").Value

access a range on a specific sheet
Range("Sheet1!MyRange").Value

access a range in another open workbook
Range("[Book1.xls]MyRange").Value

access a range on a specific sheet in another workbook
Range("[Book1.xls]Sheet1!MyRange").Value


Hope this helps

Sandy


Barb Reinhardt wrote:
I have created a named range with a single value in it and I can't seem to
access it within my VBA code. This is what I have so far. I've put it in
a debug.print statement to see if I can see what's going on and it gacks each
time.

Debug.Print Range("P_bar").Text
Debug.Print Range("P_bar").Value

I get a

Runtime error '1004'
Method 'range' of object '_Global' failed.

I can access the named range from the worksheet, just not the macro. The
named range is a workbook range, not a worksheet range.

Thanks,


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Range Name issue

use Application.Evaluate("P_bar")

--
Haldun Alay

"Barb Reinhardt" , haber iletisinde
şunları ...
I have created a named range with a single value in it and I can't seem to
access it within my VBA code. This is what I have so far. I've put it
in
a debug.print statement to see if I can see what's going on and it gacks
each
time.

Debug.Print Range("P_bar").Text
Debug.Print Range("P_bar").Value

I get a

Runtime error '1004'
Method 'range' of object '_Global' failed.

I can access the named range from the worksheet, just not the macro. The
named range is a workbook range, not a worksheet range.

Thanks,



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Range Name issue

to access a named range w/code use the following:

for accessing on an active sheet
Range("MyRange").Value

access a range on a specific sheet
Range("Sheet1!MyRange").Value

access a range in another open workbook
Range("[Book1.xls]MyRange").Value

access a range on a specific sheet in another workbook
Range("[Book1.xls]Sheet1!MyRange").Value


Hope this helps

Sandy


Barb Reinhardt wrote:
I have created a named range with a single value in it and I can't seem to
access it within my VBA code. This is what I have so far. I've put it in
a debug.print statement to see if I can see what's going on and it gacks each
time.

Debug.Print Range("P_bar").Text
Debug.Print Range("P_bar").Value

I get a

Runtime error '1004'
Method 'range' of object '_Global' failed.

I can access the named range from the worksheet, just not the macro. The
named range is a workbook range, not a worksheet range.

Thanks,




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Range Name issue

to access a named range w/code use the following:

for accessing on an active sheet
Range("MyRange").Value

access a range on a specific sheet
Range("Sheet1!MyRange").Value

access a range in another open workbook
Range("[Book1.xls]MyRange").Value

access a range on a specific sheet in another workbook
Range("[Book1.xls]Sheet1!MyRange").Value


Hope this helps

Sandy


Barb Reinhardt wrote:
I have created a named range with a single value in it and I can't seem to
access it within my VBA code. This is what I have so far. I've put it in
a debug.print statement to see if I can see what's going on and it gacks each
time.

Debug.Print Range("P_bar").Text
Debug.Print Range("P_bar").Value

I get a

Runtime error '1004'
Method 'range' of object '_Global' failed.

I can access the named range from the worksheet, just not the macro. The
named range is a workbook range, not a worksheet range.

Thanks,


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
Range.Select Issue AMDRIT Excel Programming 1 April 6th 06 06:20 PM
Range issue evil baby[_13_] Excel Programming 3 March 7th 06 03:59 PM
Range issue... James Excel Programming 4 August 4th 05 09:26 PM
Copy Range Issue SIGE Excel Programming 15 April 5th 05 04:57 PM
Excel Range issue Rohit Nayak Excel Programming 2 November 19th 04 03:10 PM


All times are GMT +1. The time now is 08:49 PM.

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

About Us

"It's about Microsoft Excel"