View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
RichardSchollar RichardSchollar is offline
external usenet poster
 
Posts: 196
Default Fill FromDate to ToDate

Chuck

Try the following macro (stick it in a standard module in the workbook
concerned and hit run):

Sub Test()
Dim d1 As Long, d2 As Long, rng As Range, i As Long
With Sheets("Sheet1")
d1 = .Range("FromDate")
d2 = .Range("ToDate")
End With
If d1 <= d2 Then
With Sheets("Sheet2")
.Activate
.Range("H8:H" & .Range("H65536").End(xlUp).Row).ClearContents
.Range("H8").Activate
For i = d1 To d2 Step 1
Set rng = ActiveCell
rng.Value = i
ActiveCell.Offset(1, 0).Activate
Next
.Range("H8:H" & .Range("H65536").End(xlUp).Row).NumberFormat =
"ddmmmyyyy"
End With
End If
End Sub

Hope it helps!

Richard


CLR wrote:
Hi All........
I need some help, if someone please. I have a cell Sheet1I4 named
"FromDate" and another Sheet1J4 named "ToDate". I would like to put
"FromDate" in Sheet2H8 and fill down column H until the value in "ToDate" is
reached......it may be only a few days, or several months, depending on the
dates set in by the user. I've tried recording the macro, but of course that
don't work for beans.......any help would be much appreciated.

Vaya con Dios,
Chuck, CABGx3