Results 1 to 11 of 11

Delete all Named Ranges in another workbook

Threaded View

  1. #1
    Registered User
    Join Date
    08-27-2007
    Location
    Australia
    Posts
    60

    Delete all Named Ranges in another workbook

    Hi All,

    I have a VBA code that creates another workbook and copies a sheet to that workbook;

    ' Create New Workbook
    Dim wb As Workbook
    Set wb = Workbooks.Add
    ThisWorkbook.Sheets(MySheetName).Copy Before:=wb.Sheets(1)
    When copying the sheet, all the named ranges associated with it copy over as well.

    I want to delete all named ranges - in the new workbook only - , this is the code I thought would work;

    Dim MyName As Name
    For Each MyName In Names
    Workbooks("Book1").Names(MyName.Name).Delete
    Next
    However it doesn't do the trick;

    Run-time error 1004
    The name that you have entered is not valid.
    Capture.PNG

    However the name of the spreadsheet created is "Book1", any ideas?

    Thanks
    Last edited by tejay; 11-09-2015 at 08:45 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] How to Delete Named Ranges in A specific Sheet
    By Romulo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-12-2013, 08:05 PM
  2. Duplicate Named Ranges, how to specify which one to delete
    By treygriffin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-11-2013, 10:45 AM
  3. Delete named ranges from selection
    By AlvaroSiza in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-17-2012, 05:20 PM
  4. delete a bunch of named ranges
    By Takeadoe in forum Excel General
    Replies: 2
    Last Post: 06-30-2006, 07:35 AM
  5. How do I delete all named ranges in a sheet at one time?
    By L.Wall in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  6. How do I delete all named ranges in a sheet at one time?
    By Dave Peterson in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-06-2005, 06:05 AM
  7. [SOLVED] How do I delete all named ranges in a sheet at one time?
    By L.Wall in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  8. [SOLVED] How do I delete all named ranges in a sheet at one time?
    By L.Wall in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1