问题
Is it possible to clear Excel cell format and content (using VBA) without altering the “NumberFormat
” of the given cell.
I’ve tried with “.ClearContents
” & “.ClearFormats
”, but ClearFormats removed the NumberFormat of the cells too.
Please suggest.
回答1:
You could do something like this:
Dim t
t = Range("A1").NumberFormat
Range("A1").ClearFormats
Range("A1").NumberFormat = t
It will save the number format then reapply it after clearing everything else.
来源:https://stackoverflow.com/questions/35923490/clear-the-excel-cells-format-using-vba-without-clearing-the-numberformat