Results 1 to 5 of 5

Subtract one day from date

Threaded View

  1. #1
    Registered User
    Join Date
    03-02-2011
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2003
    Posts
    5

    Subtract one day from date

    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?
    Last edited by karlkr245; 03-09-2011 at 03:10 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1