Results 1 to 7 of 7

Excel 2007 : Fill gap between dates

Threaded View

  1. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Fill gap between dates

    Try this in the workbook module
    Option Explicit
    
    Private Sub Workbook_Open()
        Dim LastRow As Long, RowNo As Long
    
        With Sheets("Sheet1")
            LastRow = .Range("A" & Rows.Count).End(xlUp).Row
            If .Range("A" & LastRow) < Date - 1 Then
                If .Range("A" & LastRow).Offset(0, 1) = "" Then
                    .Range("A" & LastRow).Offset(0, 1) = .Range("A" & LastRow).Offset(-1, 1)
                    .Range("A" & LastRow).Offset(0, 2) = "Automated Entry"
                End If
                For RowNo = LastRow To LastRow + Date - .Range("A" & LastRow) - 1
                    If .Range("A" & RowNo + 1) = "" Then
                        .Range("A" & RowNo + 1) = .Range("A" & RowNo) + 1
                        If .Range("A" & RowNo + 1) <> Date Then
                            .Range("A" & RowNo + 1).Offset(0, 1) = .Range("A" & RowNo + 1).Offset(-1, 1)
                            .Range("A" & RowNo + 1).Offset(0, 2) = "Automated Entry"
                        End If
                    End If
                Next
    
            End If
        End With
    End Sub

    When you open this demo with macros enabled it will automatically add the missing data.
    To test
    Delete the last few rows (A:C) save the workbook, close, and reopen.
    then
    Delete the last few rows (A:C) plus what becomes the last row Column B, save the workbook, close, and reopen

    Note: This will not fill missing entries in old sheets with missing data, it will only work from the last entered date forward.
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

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