Use VBA to replace 2002 by 2004 in Date
I'm absolutely stumped. I've tried many things:
Code as part of my very long VBA code on an xla
Code seperate as part of the workbook
Code with wokbook, worksheet & range fully defined
All kind of changes in my dateformat,
etc.
etc.
It makes no difference, it refuses to work. I think I know why: it
doesn't see the cell as 31-12-2003 but as 37986.
As solution I've found:
Sub Macro1()
For Each c In ActiveSheet.UsedRange
If Left(c.Text, 5) = "31-12" Then c.Formula = "31-12-2004"
Next c
End Sub
But this is, as far as I can see, a lot more work for excel and thus
very much slower. In addition, why does it work for you and not for
me? Are your cells also fomatted as dates or as text?
Leo
On Mon, 22 Dec 2003 14:02:58 -0700, "Jake Marx"
wrote:
Hi Leo,
Where did you put the code? In a standard module? If so, are the dates to
be replaced on the active worksheet? You may want to try the following
statement, which is more explicit:
Sheets("Sheet1").UsedRange.Replace What:="31-12-????", _
Replacement:="31-12-2004", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
|