Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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").Va lue 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 -- JB |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub UserForm_Initialize()
Dim startweek As Date Dim thisweek As Date startweek = "04/06/2006" thisweek = ThisWorkbook.Worksheets("FormData").Range("K8").Va lue 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) "johnboy" wrote in message ... 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").Va lue 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 -- JB |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
bob,
thanks for quick reply & solving for me! - your help is very much appreciated. -- JB "Bob Phillips" wrote: Private Sub UserForm_Initialize() Dim startweek As Date Dim thisweek As Date startweek = "04/06/2006" thisweek = ThisWorkbook.Worksheets("FormData").Range("K8").Va lue 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) "johnboy" wrote in message ... 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").Va lue 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 -- JB |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Dateadd function | Excel Discussion (Misc queries) | |||
dateadd | Excel Discussion (Misc queries) | |||
DateAdd | Excel Programming | |||
Using DateAdd with a text string | Excel Programming | |||
DateAdd function | Excel Programming |