+ Reply to Thread
Results 1 to 11 of 11

Delete all Named Ranges in another workbook

  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;

    Please Login or Register  to view this content.
    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;

    Please Login or Register  to view this content.
    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.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,717

    Re: Delete all Named Ranges in another workbook

    Look at this link.

    http://www.vbaexpress.com/kb/getarticle.php?kb_id=219
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Delete all Named Ranges in another workbook

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 11-09-2015 at 09:00 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

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

    Re: Delete all Named Ranges in another workbook

    Hi all,

    Thanks for the ideas, I tried both suggestions - alansidman last.

    On both methods, VBA gets caught here with the same error message as my original post;

    Capture.PNG

    Any further ideas?

    Thanks

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,717

    Re: Delete all Named Ranges in another workbook

    Do any of your range names contain any of the issues referred to in your error message?

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

    Re: Delete all Named Ranges in another workbook

    Post duplicated, see below.
    Last edited by tejay; 11-10-2015 at 04:35 AM.

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

    Re: Delete all Named Ranges in another workbook

    Hi Again,

    No this is not the case.

    To test, I deleted out all the name ranges and just added one;
    - "Deleteme" with a reference to a single cell in the workbook.

    See the example below;
    Example.xlsm

    Looks like some silly excel glitch...

    Thanks

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

    Re: Delete all Named Ranges in another workbook

    Grrr, when I download that spreadsheet it actually works for me even though it didn't before saving it.

    It seems to be something to do with the content of my workbook.

    If I delete all names and add a fresh one "test" I get this series of errors;

    Attachment 429446
    Attachment 429447
    Attachment 429448

    However if I delete all content from my workbook AND close it (saving isn't enough).
    Than when I open it again, the code will work.

    Why would content within my workbook be effecting this code?

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

    Re: Delete all Named Ranges in another workbook

    I can however delete named ranges one at a time via;

    Please Login or Register  to view this content.
    Last edited by tejay; 11-10-2015 at 06:16 AM.

  10. #10
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,717

    Re: Delete all Named Ranges in another workbook

    I have tested the codes provided for removing names. They work for me. I am unable to reproduce your error message. Suggest you upload your workbook for analysis.

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

    Re: Delete all Named Ranges in another workbook

    Just to finalise this thread, it was something silly within my workbook - never found out what.
    Just had to delete each named range one by one using vba.

+ Reply to Thread

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. [SOLVED] 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. 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