Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Why doesn't this work...??

Trying to get this piece of code to compile. All I want to
do is to cycle through the range names in a workbook and
assign details to some variables. It bugs out though...

Dim nm as object

For Each nm In ActiveWorkbook.Names

rng_name = nm.Name // this works ok
rng_sheet = nm.Worksheet.Name // this bugs out
rng_add = nm.Address // this also bugs out

Next nm

Any help much appreciated

Chris
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Why doesn't this work...??

Dim rng as Range
Dim nm as Name
Dim rng_sheet as String
Dim rng_add as String
Dim nm as Name
For Each nm In ActiveWorkbook.Names

rng_name = nm.Name '// this works ok
On Error Resume Next
set rng = nm.RefersToRange
On Error goto 0
if not rng is nothing then
rng_sheet = rng.parent.Name '// this bugs out
rng_add = rng.Address '// this also bugs out
' or
'rng_add = nm.Refersto
else
rng_sheet = ""
rng_add = ""
end if
Next nm

Regards,
Tom Ogilvy

Note that you can have defined names that don't refer to ranges. That is
what the error checking is all about.

--
Regards,
Tom Ogilvy


Chris Gorham wrote in message
...
Trying to get this piece of code to compile. All I want to
do is to cycle through the range names in a workbook and
assign details to some variables. It bugs out though...

Dim nm as object

For Each nm In ActiveWorkbook.Names

rng_name = nm.Name // this works ok
rng_sheet = nm.Worksheet.Name // this bugs out
rng_add = nm.Address // this also bugs out

Next nm

Any help much appreciated

Chris



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
Macro to update a column in a work based on another work sheet WickerMan New Users to Excel 1 December 4th 09 12:58 PM
how can i automatically generate work order numbers from work orde rob h Excel Discussion (Misc queries) 1 July 13th 09 07:59 PM
flash object dont work in my excel work sheet Nitn Excel Discussion (Misc queries) 0 July 4th 09 08:00 AM
Counting dates in multiple work sheets and work books Savage Excel Discussion (Misc queries) 0 December 19th 05 11:41 PM
Is there away to keep "auto save" from jumping to the first work sheet in the work book? Marc New Users to Excel 2 April 21st 05 01:27 AM


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