Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 05-03-2016, 09:25 AM
carlos_cs carlos_cs is offline Timeline - loop through all dates between first and last given and add date to column if not found Windows 10 Timeline - loop through all dates between first and last given and add date to column if not found Office 2013
Novice
Timeline - loop through all dates between first and last given and add date to column if not found
 
Join Date: May 2016
Posts: 6
carlos_cs is on a distinguished road
Default

I managed to get the answer. I'll post here just in case somebody has the same problem!

Sub timeline()
Dim i As Long
Dim ws As Worksheet
Dim ts As Worksheet
Set ws = Sheets("Sheet15") 'Change to your Output Sheet
Set ts = Sheets("Sheet14") 'Change to your data sheet
With ws
i = ts.Range("A" & ts.Rows.Count).End(xlUp).Row
ts.Range("A1:C" & i).Copy .Range("A1")
.Range("A1:C" & i).Sort Key1:=.Range("A2"), Order1:=xlAscending, _
key2:=.Range("C2"), Order2:=xlAscending, _
Header:=xlYes
Do Until i = 2
If .Cells(i, 1).Value2 = .Cells(i - 1, 1).Value2 Or .Cells(i, 1).Value2 = .Cells(i - 1, 1).Value2 + 1 Then
i = i - 1
Else
.Rows(i).Insert
.Cells(i, 1).Value = .Cells(i + 1, 1).Value2 - 1
.Cells(i, 2).Value = 0#
.Cells(i, 3).Value = "--"
End If
Loop
End With
End Sub
Reply With Quote
 

Tags
date, loops, timeline



Similar Threads
Thread Thread Starter Forum Replies Last Post
Autofill dates - how can I get the same date and consecutive dates? Exhale Excel 3 04-05-2016 03:11 AM
Timeline - loop through all dates between first and last given and add date to column if not found Loop Macro to Edit Date damaniam Word VBA 7 02-21-2014 07:12 AM
Timeline - loop through all dates between first and last given and add date to column if not found Loop action in Word until not found kilburfi Word VBA 2 07-12-2013 01:26 AM
Timeline - loop through all dates between first and last given and add date to column if not found Timeline date format mikeg Project 1 04-19-2013 06:26 AM
Timeline - loop through all dates between first and last given and add date to column if not found Automatically enter date into a column and make that column read only Mr Davo Excel 1 10-29-2012 01:07 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:39 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft