![]()
Sub ef() Dim r As Range Dim cell As Range Dim d As Double On Error Resume Next Set r = ActiveWindow.RangeSelection.SpecialCells(xlCellTypeConstants, xlNumbers).Cells If Err.Number Then GoTo NothingToDo For Each cell In r.Cells If VarType(cell.Value) <> vbDate Then d = Int(cell.Value2) Select Case d Case 1000 To 9999 cell.Value = CDate(Format(d, "0-0-00")) Case 10000 To 999999 cell.Value = CDate(Format(d, "0-00-00")) Case Is > 100000 cell.Value = CDate(Format(d, "0-00-0000")) End Select End If Next cell NothingToDo: End Sub
Bookmarks