Hi Rozent,
can a macro change the definision in the control panel?
I am not aware of a means to effect a global change with a custom format.
If you refer to the length of the code, I really do not believe that this
should be a consideration.
If you refer to macro execution time,
you could wrap the code thus:
Application.ScreenUpdating = False
'code
application.ScreenUpdating = True.
If you were happy to limit processing to existing date values, as opposed to
custom formatted cells which might (or might not) contain values, then
increased efficiency might ensue by changing:
to:
Set rng = SH.UsedRange.SpecialCells _
(xlCellTypeConstants, xlNumbers)
For date values entered as constants.
If, with the preceding limitation to existing date values, such dates were
returned from formulae, then you could use a range assignment like:
Set rng = SH.UsedRange.SpecialCells _
(xlCellTypeFormulas, xlNumbers)
If the dates of interest potentially result from either constants or
formulae, you would need to loop through each of the SpecialCells ranges or
form a union. This would increase code length but might wll improve
execution time
As written, the suggested code changes the custom format irrespective of
whether the formatted cells are currently populated.