Filling Series of columns with Dates

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In VB code I need to fill a range of columns with dates. Starting in column
P1 going to the right, I need to automatically fill the dates based on todays
date for 90 days. Then I change the orientation of those 90 cells to -90
degrees.
 
Hi Bill,

P1 going to the right, I need to automatically fill the dates based on todays
date for 90 days. Then I change the orientation of those 90 cells to -90
degrees.
.

in other words: you want the days starting at P1 and
continuing in P2, P3 a.s.o.? Do you mean that by "change
orientation to -90 degrees"? This could go easier like
follows:

For i = 1 To 90
Range("P" & i).Formula = "=today()+" & (i - 1)
Next i

Best

Markus
 
Sub Macro1()
Dim rng As Range
Range("P1").Value = "1/15/2004"
Set rng = Range("Q1").Resize(1, 89)
rng.Formula = "=P1+1"
rng.Formula = rng.Value
rng.NumberFormat = Range("P1").NumberFormat
Range(Range("P1"), rng).Orientation = -90

End Sub
 
No, I need the dates to fill the first row P1, Q1, R1, S1 a.s.o. As for the
orientation change, I need to change the date from being horizontal and turn
the date negative 90 degrees. I want the VB code to do this. You can see
what I am referring to by bringing up the format cells dialog box and
clicking on the Alignment tab, in the orientation box change the text to -90
degrees.
 
Hi Bill,

sorry, I misunderstood you...

then you should use Toms code instead of mine ;o)

Best

Markus
 
Tom and Markus

Thank you both for you help. Tom the code worked superbly. Thanks again.

Bill
 
Bill,

Maybe this

Dim i As Long

With Range("P1")
For i = 0 To 89
With .Offset(0, i)
.Value = Date + i
.NumberFormat = "dd mmm yyyy"
End With
Next i
.Resize(1, 90).Orientation = -90
End With


--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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

Back
Top