+ Reply to Thread
Results 1 to 19 of 19

How do I delete styles?

  1. #1
    Forum Contributor
    Join Date
    08-17-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    106

    How do I delete styles?

    I have used a macro to remove corrupt styles and removed 35k of them. My file still has a few hundred styles that I can't seem to delete. When I right click on the style and select delete nothing happens. If I click apply it returns the message Stlyle '2 2' not found. 2 2 was the style I was trying to apply. I am getting some weird characters in my styles as well. How do I delete these unwanted and unused styles?

    Thanks

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: How do I delete styles?

    The help file offers this:

    Please Login or Register  to view this content.
    And this will list them:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Contributor
    Join Date
    08-17-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    106

    Re: How do I delete styles?

    THe first code didn't appear to do anything. The second code changed a bunch of cells in a pivot table to these weird format names. Do pivot tables require these weird formats? I am trying to clean up a spreadsheet and this just doesn't seem right. Thanks for any advice.

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: How do I delete styles?

    Well the second code should have written the names of the styles in whatever sheet you had activated - perhaps you should have used a blank sheet for that?

  5. #5
    Forum Contributor
    Join Date
    08-17-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    106

    Re: How do I delete styles?

    Ok, it doesn't matter to me where they get written. How do I delete them after that?

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: How do I delete styles?

    After you list them and remove any that you want to keep from the list - let's say your list is in column A

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    08-17-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    106

    Re: How do I delete styles?

    When I try your sub DelStyles I get an error. Run-time error '1004': Delete method of Style class failed When I debug "ActiveWorkbook.Styles(S).Delete" is highlighted

    What am I doing wrong? The styles are listed in column A. Thanks for your help.

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: How do I delete styles?

    Hi Dave,

    I listed the styles that I have and deleted the "Bad" style - there was no hitch

  9. #9
    Forum Contributor
    Join Date
    08-17-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    106

    Re: How do I delete styles?

    I was searching out the error message and it does seem to be related to deleting styles. For some reason these styles will not delete. Here is an example of some of the styles that won't delete.
    2 3 2
     2 3 2
    2 3 3
     2 3 3
    2 3 4
     2 3 4
    2 4
     2 4
    2 4 2
     2 4 2
    "콤냡?<$??: `1_1 "
    콤마 [0]_
    콤마_
    C¥AØ_ FAB AIA¤
    Ç¥ÁØ_´ëºñÇ¥ (2)_1_ºÎ´ëÅä°ø
    C¥AØ_´eºnC¥ (2)_ºI´eAa°ø
    Ç¥ÁØ_´ëºñÇ¥ (2)_ºÎ´ëÅä°ø
    C¥AØ_¸AAa.¼OAI
    Ç¥ÁØ_»ç¾÷ºÎº° ÃÑ°è


    Some of the special charaters didn't copy.

  10. #10
    Forum Contributor
    Join Date
    08-17-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    106

    Re: How do I delete styles?

    I have attached a small spreadsheet with these pesky styles. If you can figure out how to delete them that would be awesome. I have tried everything I know. Thanks
    Attached Files Attached Files

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: How do I delete styles?

    Save in symbolic link (SLK) format, close, and reopen.
    Entia non sunt multiplicanda sine necessitate

  12. #12
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: How do I delete styles?

    @ shg - Wow! Thanks! - I was going to call in the Cavalry!

    (How many rep points do I now bestow?)

  13. #13
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: How do I delete styles?

    Thanks -- It will only work for a single-worksheet workbook.

  14. #14
    Forum Contributor
    Join Date
    08-17-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    106

    Re: How do I delete styles?

    Any other suggestions since my workbook that I am trying to clean up is about 30 worksheets with numerous complexities that would make it a real pain and probably weeks worth of rework if I had to do each sheet then rebuild.

  15. #15
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: How do I delete styles?

    Maybe https://sergeig888.wordpress.com/2011/03/21/net4-0-version-of-the-xlstylestool-is-now-available/

    Haven't used it, so I can't make a recommendation.

    I did something else that worked, but can't promise it won't make your problem worse.

    Save a new workbook by some name ("scratch.xlsx"), change the extension to zip, and open it. Navigate to xl/styles.xml and copy that to your desktop.

    Change the extension of your problematic file to zip, replace styles.xml with the one from the new file, rename as xlsx, and open. After Excel stops whining about repairs, the bad styles are gone.
    Last edited by shg; 02-13-2015 at 05:49 PM.

  16. #16
    Forum Contributor
    Join Date
    08-17-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    106

    Re: How do I delete styles?

    shg

    Its worth a shot, I'll give it a try. I couldn't get your link to open.

    Thanks for the help.
    Dave

  17. #17
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: How do I delete styles?

    You're welcome, good luck.

  18. #18
    Forum Contributor
    Join Date
    08-17-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    106

    Re: How do I delete styles?

    shg,

    I'll give it a try. I can't seem to get your link to open though.
    Thanks for your help!

    Dave

  19. #19
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: How do I delete styles?

    Quote Originally Posted by Dave H View Post
    I can't seem to get your link to open though.
    Dunno, Dave, just checked it again and it works fine for me.

+ 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] Delete all non-custom styles
    By AlvaroSiza in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-04-2013, 07:27 PM
  2. How to delete cell styles?
    By meyestone in forum Excel General
    Replies: 7
    Last Post: 01-11-2012, 04:56 PM
  3. Excel 2007 : Delete Built-in Cell Styles
    By miroth in forum Excel General
    Replies: 1
    Last Post: 04-30-2010, 12:04 AM
  4. [SOLVED] Macro to delete un used styles in a workbook!
    By John in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-26-2005, 05:06 PM
  5. Macro that will delete any un used styles.
    By Tom in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-07-2005, 03:06 PM

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