Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-02-2016, 07:35 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 Timeline - loop through all dates between first and last given and add date to column if not found

what i have in columns A, B, C:


Date Hours Name
01/03/2016 8,0 John
02/03/2016 8,0 John
08/03/2016 7,5 John
08/03/2016 2,0 Charles
08/03/2016 2,0 William
10/03/2016 3,5 Charles


11/03/2016 3,7 Charles
14/03/2016 2,2 Charles
15/03/2016 8,0 John
16/03/2016 8,0 John

what i want in column A, B, C in another sheet:


Date Hours Name
01/03/2016 8,0 John
02/03/2016 8,0 John
03/03/2016 0,0 -
04/03/2016 0,0 -
05/03/2016 0,0 -
06/03/2016 0,0 -
07/03/2016 0,0 -
08/03/2016 7,5 John
08/03/2016 2,0 Charles
08/03/2016 2,0 William
09/03/2016 0,0 -
10/03/2016 3,5 Charles
11/03/2016 3,7 Charles
12/03/2016 0,0 -
13/03/2016 0,0 -
14/03/2016 2,2 Charles
15/03/2016 8,0 John
16/03/2016 8,0 John

It has to work with any given dates, hours and names!

Please help i really need this!

Last edited by carlos_cs; 05-02-2016 at 08:41 AM. Reason: Forgot to mention there could be more than one entry for a given date!!
Reply With Quote
  #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
Reply

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 04:28 AM.


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