S
Sami82
Hi All,
I have written the following code to display the dates on a row which
occur between two dates (sdate and edate). These are all mondays. I am
having two problems with this.
1. I want the form to work out the number of weeks between these two
dates (currently you have to type in the amount of weeks). And then i
want this number to automatically update on the form when the end date
has been entered.
2. The dates appear on the excel sheet as 1900 even when i have entered
the dates in the form as dd/mm/yyyy.
Thanks for the help.
rivate Sub PromoDatesOK_Click()
Dim sdate As Date
Dim edate As Date
Dim cnt As Integer
Dim wknumtot As Integer
'ActiveWorkbook.Sheets("Claim").Activate
Range("a1").Select
wknumtot = cboweeks.Value
ActiveCell.Value = wknumtot
sdate = Val(sdatebox.Value) - 1
edate = edatebox.Value
Range("d6").Select
ActiveCell.Value = sdate
cnt = 1
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(0, 1).Select
ActiveCell = ActiveCell.Offset(0, -1) + 7
cnt = cnt + 1
End If
Loop Until cnt = wknumtot
Unload Me
End Sub
I have written the following code to display the dates on a row which
occur between two dates (sdate and edate). These are all mondays. I am
having two problems with this.
1. I want the form to work out the number of weeks between these two
dates (currently you have to type in the amount of weeks). And then i
want this number to automatically update on the form when the end date
has been entered.
2. The dates appear on the excel sheet as 1900 even when i have entered
the dates in the form as dd/mm/yyyy.
Thanks for the help.
rivate Sub PromoDatesOK_Click()
Dim sdate As Date
Dim edate As Date
Dim cnt As Integer
Dim wknumtot As Integer
'ActiveWorkbook.Sheets("Claim").Activate
Range("a1").Select
wknumtot = cboweeks.Value
ActiveCell.Value = wknumtot
sdate = Val(sdatebox.Value) - 1
edate = edatebox.Value
Range("d6").Select
ActiveCell.Value = sdate
cnt = 1
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(0, 1).Select
ActiveCell = ActiveCell.Offset(0, -1) + 7
cnt = cnt + 1
End If
Loop Until cnt = wknumtot
Unload Me
End Sub