VB 39
Excel VBA add to all dates in sheet By mike on 28th March 2021 03:57:40 PM
  1. Sub DateConvFormat()
  2.     Dim Rng As Range
  3.     Dim Cell As Range
  4.     Dim FormulaCells As Range
  5.     Dim ConstCells As Range
  6.  
  7.    If ActiveWorkbook.Date1904 = True Then
  8.         ActiveWorkbook.Date1904 = False
  9.         Else
  10.         Exit Sub
  11.    End If
  12.  
  13.    On Error Resume Next
  14.  
  15.    Set FormulaCells = Me.UsedRange.SpecialCells(xlFormulas, xlNumbers)
  16.    Set ConstCells = Me.UsedRange.SpecialCells(xlConstants, xlNumbers)
  17.    Set Rng = Union(FormulaCells, ConstCells)
  18.  
  19.    For Each Cell In Rng
  20.         If IsDate(Cell) Then
  21.             Cell.Value = Cell.Value + 1462
  22.             Cell.Interior.Color = vbGreen
  23.         End If
  24.    Next Cell
  25.  
  26. End Sub

Hasta la pasta! is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.