automatic calendar problem

G

Gordon Blackstone

hello everyone!

i'm building a calendar to plan a project with different tasks.
i want to have n numbers of colums representing days automaticaly
generated acording to the start date and the end date.

example:

lets say "a1" is start date (ex: 1st of january 06) and "a2 "end date
(ex: 10th of january 06)

how to create 10 cells automatically (start date - end date = 10 days)
with each correct date in those cells (in c1, d1, e1 ... l1)?


thanks for your clever help!
 
G

Gordon Rainsford

Sub dateHeaders()

Dim startDate As Date
Dim endDate As Date
Dim dateDiff As Integer
Dim i As Integer

startDate = Range("A1").Value
endDate = Range("B1").Value
dateDiff = endDate - startDate

For i = 0 To dateDiff
Cells(1, i + 3).Value = startDate + i
Next i

End Sub


Or, you could copy your start date to cell "C1" and use
Edit-Fill-Series, select 'Row', 'Date', 'Day' and copy an paste your
cell "B1" value in as the stop value.
 
J

JE McGimpsey

Gordon Blackstone said:
i'm building a calendar to plan a project with different tasks.
i want to have n numbers of colums representing days automaticaly
generated acording to the start date and the end date.

example:

lets say "a1" is start date (ex: 1st of january 06) and "a2 "end date
(ex: 10th of january 06)

how to create 10 cells automatically (start date - end date = 10 days)
with each correct date in those cells (in c1, d1, e1 ... l1)?

One way:

C1: =A1
D1: =IF(C1<$A$2,C1+1,"")

Format D1 as a date and copy to the right for you maximum n columns.
 
G

Gordon Blackstone

Sub dateHeaders()

Dim startDate As Date
Dim endDate As Date
Dim dateDiff As Integer
Dim i As Integer

startDate = Range("A1").Value
endDate = Range("B1").Value
dateDiff = endDate - startDate

For i = 0 To dateDiff
Cells(1, i + 3).Value = startDate + i
Next i

End Sub

??? how to insert this? macro?
 
G

Gordon Rainsford

Gordon Blackstone said:
??? how to insert this? macro?

Yes, insert it into a module of your worksheet using the Visual Basic
Editor. If you're not comfortable doing this, you may find one of the
other given solutions suits your needs better. (Or look up Visual Basic
Editor in Excel help, and start an adventure!)
 
G

Gordon Blackstone

One way:

C1: =A1
D1: =IF(C1<$A$2,C1+1,"")

Format D1 as a date and copy to the right for you maximum n columns.

again thanks, all of you for your help.
i googled this morning with the key words "gantt chart excel" and i've
found exciting examples!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top