Search code examples
vbaexcelexcel-formulaexcel-2007

Remove the unknown format in Cell styles


While copying the data from different workbook, importing of ranges created a mess as shown in the pic. Steps to see Home tab--styles ribbon--cell styles

Not sure how to fix this. enter image description here

Kinldy help.


Solution

  • Worked this out in at least one instance - didn't find it on the web so hopefully helps you if you have the same issue...

    add code to "unlock" or unprotect the style first before deleting it. Below is the code modified from the Mr Excel (I think) forum...

        For Each styT In ActiveWorkbook.Styles
            If Not styT.BuiltIn Then
                styT.Locked = False
                styT.Delete
            End If
        Next styT