Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Delete Specific Range Names

I want to delete specific range names. The following code
reads the range names from the 1st row
of "Formatted_Input" worksheet into an array. That part
works, but I'm not familiar enough with the "Names"
property to know how to make it delete the ranges whose
names are in the MyArray array.
When I run it I get a "type mismatch" in the "For Each
Name in MyName" statement. I'd appreciate very much a fix
and a brief explanation of what's going on. Many thanks
and Happy Holidays!

Sub DeleteSelectRanges()
Dim MyArray(1 To 256)
Dim i As Integer
Sheets("Formatted_Input").Select
For i = 1 To 200
MyArray(i) = Cells(1, i)
Next i
Names.Add Name:="MyName", RefersTo:=MyArray
For Each Name In MyName
Name.Delete
Next Name
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Delete Specific Range Names

Sub DeleteSelectRanges()
Dim MyArray(1 To 256)
Dim i As Integer
Sheets("Formatted_Input").Select
For i = 1 To 200
MyArray(i) = Cells(1, i)
Next i
'Names.Add Name:="MyName", RefersTo:=MyArray
For i = 1 to 200
ActiveWorkbook.names(myarray(i)).Delete
Next
End Sub

--
Regards,
Tom Ogilvy

"Larry" wrote in message
...
I want to delete specific range names. The following code
reads the range names from the 1st row
of "Formatted_Input" worksheet into an array. That part
works, but I'm not familiar enough with the "Names"
property to know how to make it delete the ranges whose
names are in the MyArray array.
When I run it I get a "type mismatch" in the "For Each
Name in MyName" statement. I'd appreciate very much a fix
and a brief explanation of what's going on. Many thanks
and Happy Holidays!

Sub DeleteSelectRanges()
Dim MyArray(1 To 256)
Dim i As Integer
Sheets("Formatted_Input").Select
For i = 1 To 200
MyArray(i) = Cells(1, i)
Next i
Names.Add Name:="MyName", RefersTo:=MyArray
For Each Name In MyName
Name.Delete
Next Name
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Thanks, and one more question.


-----Original Message-----
Sub DeleteSelectRanges()
Dim MyArray(1 To 256)
Dim i As Integer
Sheets("Formatted_Input").Select
For i = 1 To 200
MyArray(i) = Cells(1, i)
Next i
'Names.Add Name:="MyName", RefersTo:=MyArray
For i = 1 to 200
ActiveWorkbook.names(myarray(i)).Delete
Next
End Sub

--
Regards,
Tom Ogilvy

"Larry" wrote in

message
...
I want to delete specific range names. The following

code
reads the range names from the 1st row
of "Formatted_Input" worksheet into an array. That part
works, but I'm not familiar enough with the "Names"
property to know how to make it delete the ranges whose
names are in the MyArray array.
When I run it I get a "type mismatch" in the "For Each
Name in MyName" statement. I'd appreciate very much a

fix
and a brief explanation of what's going on. Many thanks
and Happy Holidays!

Sub DeleteSelectRanges()
Dim MyArray(1 To 256)
Dim i As Integer
Sheets("Formatted_Input").Select
For i = 1 To 200
MyArray(i) = Cells(1, i)
Next i
Names.Add Name:="MyName", RefersTo:=MyArray
For Each Name In MyName
Name.Delete
Next Name
End Sub



.
Thanks, Tom. That worked just fine. Just one other

question, would it delete all range names of the same
names in other workbooks that were open if I didn't use
the ActiveWorkbook prefix on Names? Don't usually
consider that situation when I'm writing macros, but maybe
I should.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Thanks, and one more question.

No, it would not check other workbooks. It would either assume the
activeworkbook or raise an error - I believe it would assume the
activeworkbook (my testing indicates it does).

--
Regards,
Tom Ogilvy

"Larry" wrote in message
...

-----Original Message-----
Sub DeleteSelectRanges()
Dim MyArray(1 To 256)
Dim i As Integer
Sheets("Formatted_Input").Select
For i = 1 To 200
MyArray(i) = Cells(1, i)
Next i
'Names.Add Name:="MyName", RefersTo:=MyArray
For i = 1 to 200
ActiveWorkbook.names(myarray(i)).Delete
Next
End Sub

--
Regards,
Tom Ogilvy

"Larry" wrote in

message
...
I want to delete specific range names. The following

code
reads the range names from the 1st row
of "Formatted_Input" worksheet into an array. That part
works, but I'm not familiar enough with the "Names"
property to know how to make it delete the ranges whose
names are in the MyArray array.
When I run it I get a "type mismatch" in the "For Each
Name in MyName" statement. I'd appreciate very much a

fix
and a brief explanation of what's going on. Many thanks
and Happy Holidays!

Sub DeleteSelectRanges()
Dim MyArray(1 To 256)
Dim i As Integer
Sheets("Formatted_Input").Select
For i = 1 To 200
MyArray(i) = Cells(1, i)
Next i
Names.Add Name:="MyName", RefersTo:=MyArray
For Each Name In MyName
Name.Delete
Next Name
End Sub



.
Thanks, Tom. That worked just fine. Just one other

question, would it delete all range names of the same
names in other workbooks that were open if I didn't use
the ActiveWorkbook prefix on Names? Don't usually
consider that situation when I'm writing macros, but maybe
I should.



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
delete multiple range names mnsue Excel Discussion (Misc queries) 8 January 18th 10 10:41 PM
How to Delete blanks between a range and populate only the names inthe given range Yuvraj Excel Discussion (Misc queries) 2 November 4th 09 08:32 PM
How to delete a hundred range names at once? Dima Excel Discussion (Misc queries) 4 August 7th 08 11:26 AM
How to delete a hundred range names at once? Dima Excel Worksheet Functions 4 August 7th 08 11:26 AM
not delete worksheets from names in a range DARREN FONG Excel Discussion (Misc queries) 3 November 11th 05 05:31 PM


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