Hi, I am trying to subtract one day from the date in column A1. The dates in A1 were formatted as General (no specific number format) so I attempted to reformat them as a date(mm/dd/yyyy). I keep getting runtime error 13: type mismatch though.
Here is my code:
Sub SubOneDay()
Dim j As Integer
Dim Size As Integer
Size = ActiveSheet.UsedRange.Rows.Count
Application.MaxChange = 0.001
With ActiveWorkbook
.PrecisionAsDisplayed = False
.Date1904 = True
End With
For j = 3 To Size
Range("A1").Cells(j).Select
Selection.NumberFormat = "mm/dd/yyyy;@"
Next j
For j = 3 To Size
If Sheet1.Range("B1").Cells(j).Value < TimeValue("07:00:00") Then
Range("A1").Cells(j).Value = DateAdd("d", -1, Cells(j).Value)
End If
Next j
End Sub
Any ideas?
Bookmarks