DateAdd

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

Guest

Hi all,
I have a combobox on a form which I am trying to populate with week ending
dates (Sunday) from a fixed start point to a current date contained in a cell.

I have put together the following code but it is not giving the required
result. can someone be kind engough to tell me where I have gone wrong please.
Many thanks

Private Sub UserForm_Initialize()
Dim startweek As Date
Dim thisweek As Date
startweek = "04/06/2006"
thisweek = ThisWorkbook.Worksheets("FormData").Range("K8").Value

With ComboBox1
.Clear
For NextDate = startweek To thisweek

WeekDate = NextDate
IntervalType = "ww"
Number = 1

'change weekending to next sunday
NextDate = DateAdd(IntervalType, Number, WeekDate)
.AddItem Format(NextDate, "dd/mm/yyyy")
Next NextDate
End With
End Sub
 
Private Sub UserForm_Initialize()
Dim startweek As Date
Dim thisweek As Date
startweek = "04/06/2006"
thisweek = ThisWorkbook.Worksheets("FormData").Range("K8").Value

With ComboBox1
.Clear
NextDate = DateValue(startweek)
Do

WeekDate = NextDate
IntervalType = "ww"
Number = 1

'change weekending to next sunday
NextDate = DateAdd(IntervalType, Number, WeekDate)
.AddItem Format(NextDate, "dd/mm/yyyy")
Loop Until NextDate > thisweek
End With
End Sub



--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)
 
Back
Top