It's a VBA question. I'm trying to make sure all the dates in a selected
range of imported data are the end of their respective months. The code I
have works fine in a test worksheet when I enter the data manually, but not
in an old worksheet. This makes me wonder whether I have a data problem.
Maybe Eomonth is not evaluating the dates in the old worksheet correctly.
It should be as simple as this:
For each cel in Selection
cel.value = Eomonth(cel.value, 0)
Next cel
But when my code sees 4/30/2006 in the old worksheet, Eomonth returns 31.
"Rick Rothstein" wrote:
> Is this a VB question by any chance? And if so, did you want to physically
> change the date in A1 from whatever it is to the end of its month (thus
> losing whatever was in the cell to begin with)? If the answer to both of
> these questions are "Yes", then try this macro out...
>
> Sub ChangeDateToEndOfMonth()
> With Range("A1")
> .Value = DateSerial(Year(.Value), Month(.Value) + 1, 0)
> End With
> End Sub
>
> --
> Rick (MVP - Excel)
>
>
> "Stratuser" <(E-Mail Removed)> wrote in message
> news
3A36E2A-21CB-4FC1-91A9-(E-Mail Removed)...
> > If cell "a1" has a date, how could I check whether the date is the end of
> > the
> > month and if not change it to the end of the month?
> >
> >
>
>