#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default DateAdd

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 380
Default DateAdd

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default DateAdd

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dateadd function Dr. Maunuk Excel Discussion (Misc queries) 2 September 28th 07 07:32 AM
dateadd The BriGuy[_2_] Excel Discussion (Misc queries) 1 March 29th 07 06:51 PM
DateAdd Michael Wise[_7_] Excel Programming 1 August 27th 04 07:40 PM
Using DateAdd with a text string Max Excel Programming 2 February 18th 04 02:10 AM
DateAdd function Bill[_19_] Excel Programming 2 November 12th 03 07:07 PM


All times are GMT +1. The time now is 12:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"