+ Reply to Thread
Results 1 to 6 of 6

how to list missing all date by blank row between change value cells?

Hybrid View

  1. #1
    Registered User
    Join Date
    06-30-2015
    Location
    muscat
    MS-Off Ver
    2007
    Posts
    5

    how to list missing all date by blank row between change value cells?

    i am looking for macro code that isert blank row between data( missing all date) when change value data which each cells are started frist month if not mentied till end of month too
    Attached Files Attached Files

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,651

    Re: how to list missing all date by blank row between change value cells?

    Try such macro (not most effective but quite strightforward to understand - I hope):

    Sub test()
    Dim i As Long, lr As Long, start_date As Date, end_date As Date, current_date As Date
    Application.ScreenUpdating = False
    
    lr = Cells(Rows.Count, "B").End(xlUp).Row
    start_date = DateSerial(2015, 5, 1)
    end_date = DateSerial(2015, 6, 1) 'note - this is first day of next month to keep one empty line
    current_date = start_date
    i = 2
    Do
      If Cells(i, "B") = current_date Then
        i = i + 1
        current_date = current_date + 1
      ElseIf Cells(i, "B") <> "" Then
        Rows(i).Insert shift:=xlDown
        i = i + 1
        current_date = current_date + 1
        lr = lr + 1
      ElseIf current_date < end_date Then
        Rows(i).Insert shift:=xlDown
        i = i + 1
        current_date = current_date + 1
        lr = lr + 1
      Else
        i = i + 1
        current_date = start_date
      End If
    Loop Until i >= lr
    End Sub
    Attached Files Attached Files
    Best Regards,

    Kaper

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,615

    Re: how to list missing all date by blank row between change value cells?

    Here's my interpretation of your problem.
    Sub test()
        Dim i As Long, ii As Long, myAreas As Areas, Sdate As Date, Edate As Date, x As Long
        Application.ScreenUpdating = False
        Set myAreas = Columns("b").SpecialCells(2, 1).Areas
        For i = myAreas.Count To 1 Step -1
            With myAreas(i)
                Sdate = .Cells(1).Value - Day(.Cells(1).Value) + 1
                Edate = DateAdd("m", 1, .Cells(1).Value) - Day(.Cells(1).Value)
                For ii = .Count To 2 Step -1
                    If ii = .Count Then
                        x = Edate - .Cells(ii).Value
                        If x > 0 Then .Cells(ii + 1).Resize(x).EntireRow.Insert
                    Else
                        x = .Cells(ii).Value - .Cells(ii - 1).Value
                        If x > 1 Then
                            .Cells(ii).Resize(x - 1).EntireRow.Insert
                        End If
                    End If
                Next
                x = .Cells(1) - Sdate
                If x > 0 Then .Cells(1).Resize(x).EntireRow.Insert
            End With
        Next
        Application.ScreenUpdating = True
    End Sub
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    06-30-2015
    Location
    muscat
    MS-Off Ver
    2007
    Posts
    5

    Re: how to list missing all date by blank row between change value cells?

    thank you too much

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,615

    Re: how to list missing all date by blank row between change value cells?

    If that takes care of your original question, select Thread Tools from the menu link above and mark this thread as SOLVED.

  6. #6
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: how to list missing all date by blank row between change value cells?

    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] If formula, if two cells are blank, return blank, if one has a date, subtract todays date
    By amthyst826 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-06-2014, 12:47 PM
  2. Something missing in my code to run macro when 2 cells change
    By bazofio in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-24-2014, 10:51 PM
  3. Excel Macro to find missing dates and insert missing date as blank row
    By JevaMarie in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-26-2013, 11:08 AM
  4. [SOLVED] find missing date on every group date list based on range and criteria
    By k1dr0ck in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-25-2013, 01:26 AM
  5. Identify Blank cells with Missing Data
    By Cortlyn in forum Excel General
    Replies: 3
    Last Post: 11-05-2012, 01:04 PM

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