I would drop the DateValue() stuff and just use dateserial:
StartDate = DateValue("020110")
becomes
StartDate = Dateserial(2010,2,1) 'ymd order
And I'd declare my variables, too:
Dim StartDate as Date
Qaspec wrote:
>
> Joel
>
> I get a Type Mismatch Error when i try to execute.
>
> The highlight shows on -
>
> StartDate = DateValue("020110")
>
> "joel" wrote:
>
> >
> > Dates are number with the first day Jan 1, 1900 and each day equal 1.
> > this code should work
> >
> >
> > Private Sub CB1_Click()
> >
> > StartDate = DateValue("020110")
> > EndDate = DateValue("022710")
> >
> >
> > With ThisWorkbook.Worksheets("February")
> > For MyDate = StartDate To EndDate
> > Yesterday = Format(MyDate - 1, "MMDDYY")
> > DateStr = Format(MyDate, "MMDDYY")
> >
> > .Range("B5").Value = _
> > Worksheets(Yesterday).Range("B5").Value + _
> > Worksheets(DateStr).Range("B5").Value
> > Next MyDate
> > End With
> > End Sub
> >
> >
> > --
> > joel
> > ------------------------------------------------------------------------
> > joel's Profile: 229
> > View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=193373
> >
> > http://www.thecodecage.com/forumz
> >
> > .
> >
--
Dave Peterson