Sub InsertDatetUntilToday() ' coded by: siti Vi / Jakarta, May 16, 2011 '------------------------------------------- Dim SeleDate As Date, DiffDate As Long, n As Long Do While ActiveCell > 0 If IsDate(ActiveCell) And ActiveCell < Date Then If Not IsEmpty(ActiveCell(2, 1)) Then SeleDate = ActiveCell.Value DiffDate = Date - SeleDate ActiveCell(2, 1).Resize(DiffDate, 1).EntireRow.Insert For n = 1 To DiffDate ActiveCell(n + 1, 1) = SeleDate + n Next n End If End If ActiveCell(n + 1, 1).Activate Loop Me.Cells(1).Activate End Sub
On Sun, May 15, 2011 at 4:32 PM, Stuart <swilson2...@gmail.com> wrote: > Hi all > > I hope someone can help with this. > > My data is in columns A to F with the short date being in column B. > > The data is sorted in date order and the first date that appears in > column B is 23/12/2002 and the next row contains the date 14/01/2002. > What I need is for a macro to look at the first date in the cell that > I have selected and then look at the next date and fill in the missing > dates until it reaches today. The data can go down in an unlimited > amount of rows. > > So basically the macro would insert a new row with the date is column > B as 24/12/2002, 25/12/2002, 26/12/2002 and so on and so forth. > > I hope this makes sense to someone > > Best regards > > Stuart > > -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel
ctv_Insert Row and Date.xls
Description: MS-Excel spreadsheet