Delete Custom Number Formats

lmoon

New Member
Joined
Aug 26, 2008
Messages
10
Hi - I've done a search and couldn't see anything which seemed to solve my problem. I have a spreadsheet into which a client has copied a number of worksheets. Unfortunately, all their custom number formats have also been copied across and I continually get the error message "too many custom number formats" and it is running very slowly. I seem to remember there being a neat VBA solve for this, but I can't find it on the interweb anywhere...anyone out there have a simple (ish) fix for this???

Thanks in advance

lmoon
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hi There

Welcome to the Board

Give this a bash

Code:
Sub clean_Format()
For Each Worksheet In ActiveWorkbook.Worksheets
    Cells.NumberFormat = "General"
Next
End Sub

Dave
 
Upvote 0
Thanks for the quick response....

tried it out, but it cleared all the formatting in my current worksheet, but hasn't deleted the custom formats from the "format cells" / "number" / "custom" which is what i was hoping to do. I'd like to get rid of any custom number formatting that is not currently being used in my worksheet.....
 
Upvote 0
Apologies

I skipped over an important point

Code:
Sub clean_Format()
Dim ws As Worksheet
For Each ws In Workbooks(ActiveWorkbook.Name).Sheets
    ws.Cells.NumberFormat = "General"
Next ws
End Sub

KR


Dave
 
Upvote 0
Thanks once again Dave.

I don't think that it's quite doing what I want, which is to delete the unused custom formats. I have heaps of "#,##0.0_)" or "#,##0.0000_)" or "0.0x" "0.000x" "0.0000x_)" which are very similar but not the same and I'd like to delete any formats which are not being used in the current worksheet so that they don't appear in the custom number box. I know you can go through and do it manually, but I'd ideally like a quick fix. (Lazy, moi?). The vba you suggest doesn't seem to delete the unused options, just returns the current worksheet to the general format....
 
Upvote 0
Hi lmoon

I apologise for not getting back on this, I have been working to try and help but up til now I have not been able to bodge you up anything that truly works.

If i were you I might look at the .DeleteNumberFormat method and see if you can do something

Sorry, I hope one of the true gurus can help.

Best Wishes


Dave
 
Upvote 0
Hi

Had a think about this, OK so I couldn't come up with a solution to removing the Custom Format types not used in the current workbook but your question does mention the formats have been copied across your book which in turn may be causing your problem.

Perhaps reseting the used range of each page might trim the file down to size, I got a book from our HQ which was 8Mb I removed the excess formatting and it (within a second) trimmed down to a meager 3Mb

>>Click Here<<

See if it gets you somewhere towards your goal

Dave
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,241
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top