View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Delete range names within a selection

on 4/29/2012, hdf supposed :
I should provide some additional information on my problem.

I realize now that the Worksheet level version doesn't do anything
because the names I am trying to erase are Workbook level.

When running the workbook version I get a run-time error. The error
is a 1004 run-time error that says, specifically, "Method 'Range' of
object '_Global' failed."

When I press the "Debug" option it highlights the following part of
Gary's code:

If Not Intersect(Selection, Range(rngname)) Is Nothing Then

If I use the exact same code on a new workbook created to test it, it
works as intended and erases the range names located within the
selected area.

I have ensured none of the worksheets nor the workbook are locked in
any way. I have also unlocked all cells to see if that would do the
trick, no luck either. I don't know what else to try.


For the code to work in any workbook, it must be stored in a standard
module and run from the Excel window via the Macros dialog. Optionally,
you can run it from the VBE -OR- store it in a standard module in
PERSONAL.XLS. I suspect that you're trying to run the code behind a
sheet module and so when you select that it activates that workbook's
worksheet.

The code will do nothing if no ranges have defined names, or the
defined names are outside the scope for the line of code running.

--
Garry

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