Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Finding a name for a range pointing to "this"?

I have a query that returns rows in a deliberately random sorting that
gets pasted into a sheet called "Input". I have a number of other
sheets that refer to data in that page, using named ranges. When I
paste in the data, I use:

theSheet.Names.Add Name:=theName, RefersToR1C1:="=Input!R" & fundLoop
& "C" & ccyLoop

to give it a Name. "theName" is a properly formatted string, similar
to "

I've noticed that if the cell in question already contains a Name,
this line of code will fail. I need to find a solution for this.

Ideally I'd like to remove any existing names that point into this
sheet. However, I can't seem to find a simple way to do this. The
Names collection has all of them, not just the ones on this sheet. Is
there a simple way to isolate these?

Maury
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Finding a name for a range pointing to "this"?

you can try this, it looks at the active sheet. it may work for you. (watch for
word wrap)

Sub name_ranges() 'this deletes all named ranges
Dim nm As Name

Select Case MsgBox("Are you Sure You Want To Delete All Named Ranges?", _
vbOKCancel Or vbExclamation Or vbDefaultButton1, Application.Name)
Case vbOK
For Each nm In ThisWorkbook.Names
If InStr(1, nm, ActiveSheet.Name) Then
nm.Delete
End If
Next nm
Case vbCancel
Exit Sub
End Select

End Sub

--


Gary

"Maury Markowitz" wrote in message
...
I have a query that returns rows in a deliberately random sorting that
gets pasted into a sheet called "Input". I have a number of other
sheets that refer to data in that page, using named ranges. When I
paste in the data, I use:

theSheet.Names.Add Name:=theName, RefersToR1C1:="=Input!R" & fundLoop
& "C" & ccyLoop

to give it a Name. "theName" is a properly formatted string, similar
to "

I've noticed that if the cell in question already contains a Name,
this line of code will fail. I need to find a solution for this.

Ideally I'd like to remove any existing names that point into this
sheet. However, I can't seem to find a simple way to do this. The
Names collection has all of them, not just the ones on this sheet. Is
there a simple way to isolate these?

Maury



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
use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" Luc[_3_] Excel Programming 2 September 28th 05 08:37 PM
Finding the current "print range" Alex T Excel Programming 1 September 2nd 04 01:38 PM
Using "Cells" to write "Range("A:A,H:H").Select" Trip Ives[_2_] Excel Programming 3 June 5th 04 03:13 PM
Pointing search function to "This Drive"? Ed[_9_] Excel Programming 2 October 16th 03 07:05 PM


All times are GMT +1. The time now is 05:08 AM.

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"