Clear cell styles but retain formatting

L

Legacy 281488

Guest
Hi all,

I have a client's spreadsheet which uses lots of cell styles.

I need to import this spreadsheet into my own workbook, but don't want to import all the cell styles across.

I have tried running a few 'Style Kill' type macros on the client's spreadsheet prior to importing, but, in addition to removing the cell styles from the library, any cell that were using a cell style revert to normal (i.e. no formatting).

Is there a way to disconnect cell formatting from cell styles, so that I can then delete the cell styles without resetting all the cells?

Many thanks in advance,
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Thanks for the tip but I have tried that add-in too... any cell formatted with a cell style which get deleted reverts to the default 'Normal' style
 
Upvote 0
I have a client's spreadsheet which uses lots of cell styles.

I need to import this spreadsheet into my own workbook, but don't want to import all the cell styles across.

I have tried running a few 'Style Kill' type macros on the client's spreadsheet prior to importing, but, in addition to removing the cell styles from the library, any cell that were using a cell style revert to normal (i.e. no formatting).

Is there a way to disconnect cell formatting from cell styles, so that I can then delete the cell styles without resetting all the cells?

Here I have used Selection, but you can change that to a specific range or ActiveSheet.UsedRange or whatever you need... does this do what you want?

Code:
Sub RemoveStyleKeepNumberFormat()
  Dim Cell As Range, Temp As Variant
  Application.ScreenUpdating = False
  For Each Cell In Selection
    Temp = Cell.NumberFormat
    Cell.ClearFormats
    Cell.NumberFormat = Temp
  Next
  Application.ScreenUpdating = True
End Sub
 
Upvote 0
Rick,

Thanks, based on my limited knowledge of VBA, it looks like the code below will do what I need... temporarily save cell format, clear format, reapply format... assuming the reapply doesn't reapply cell style but just the formatting associated with the style?

I will try first thing tomorrow morning.

Here I have used Selection, but you can change that to a specific range or ActiveSheet.UsedRange or whatever you need... does this do what you want?

Code:
Sub RemoveStyleKeepNumberFormat()
  Dim Cell As Range, Temp As Variant
  Application.ScreenUpdating = False
  For Each Cell In Selection
    Temp = Cell.NumberFormat
    Cell.ClearFormats
    Cell.NumberFormat = Temp
  Next
  Application.ScreenUpdating = True
End Sub
 
Upvote 0
2 simple solutions:
1. copy selection to Word and back (lose comments, names etc).
2. create a new style, !KEEPCellFormat. Untick ALL the boxes in the modify box. Apply it to your selection. Then delete it. The selection will be normal style, with its original formatting.
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

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