Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
Hello,
I was trying to create an archive function on a workbook. I have a formula throughout the workbook that is based on the current date using NOW(). I went in a recorded a macro of replacing the NOW() with last years date. How can I set this so that I can have the user push a button to archive the sheet and have the year based on the current date? I want to change the replacement to an argument that gives the year -1 at the time of clicking the archive button. The current recorded code follows. Thank You LWhite Cells.Replace What:="NOW()", Replacement:="Date (2004,12,31)", LookAt:= _ xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Application.CutCopyMode = False |
#2
![]() |
|||
|
|||
![]()
How about something like:
Dim myStr As String myStr = "date(" & Year(Date) - 1 & ",12, 31)" Cells.Replace What:="NOW()", Replacement:=myStr, _ LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _ searchFormat:=False, ReplaceFormat:=False LWhite wrote: Hello, I was trying to create an archive function on a workbook. I have a formula throughout the workbook that is based on the current date using NOW(). I went in a recorded a macro of replacing the NOW() with last years date. How can I set this so that I can have the user push a button to archive the sheet and have the year based on the current date? I want to change the replacement to an argument that gives the year -1 at the time of clicking the archive button. The current recorded code follows. Thank You LWhite Cells.Replace What:="NOW()", Replacement:="Date (2004,12,31)", LookAt:= _ xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Application.CutCopyMode = False -- Dave Peterson |
#3
![]() |
|||
|
|||
![]()
Thank you very much. That really helped.
LWhite |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Date updates from worksheet to chart & changes date to a date series! Help!! | Charts and Charting in Excel | |||
Date formula | Excel Discussion (Misc queries) | |||
Problem with Date format from VBA code | Excel Discussion (Misc queries) | |||
Macro and If Statement | Excel Discussion (Misc queries) | |||
Date and Time Macro | Excel Discussion (Misc queries) |