ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro stops running after file has moved (https://www.excelbanter.com/excel-programming/320061-macro-stops-running-after-file-has-moved.html)

LWhite

Macro stops running after file has moved
 
Hello,

I have a macro that goes through an entire workbook and
replaces every instance of NOW() with the current date -
1 year. I recorded the macro and received some help on
the proper syntax for replacing with the year old date.
After using the code I ran the macro and it worked. I
then created a button and copied the code into it and
that worked fine as well.

After making multiple copies and running the macro and
button repeatedly I copied the workbook onto my network
and asked someone else to test it. This failed so I
copied the file back to my hard drive and got it to
running again by running the replace manually. After the
manual run I started copying back new copies from the
network again and they ran fine. Another copy saved to
the network stopped working again.

Any ideas why this is happening?

Sheets("Vac&Sick").Select
Range("K1").Select
Cells.Replace What:="NOW()", Replacement:="date(" &
Year(Date) - 1 & ",12, 31)", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False,
SearchFormat:=False, _
ReplaceFormat:=False
Application.CutCopyMode = False
Range("B2").Select
ActiveWorkbook.Save

LWhite

Jim Rech

Macro stops running after file has moved
 
This failed

Not much to go on. If the tester had Excel 2000 or earlier the
"SearchFormat:=False, _
ReplaceFormat:=False" part will fail since it's not supported. You can
safely delete it I think.

--
Jim Rech
Excel MVP
"LWhite" wrote in message
...
| Hello,
|
| I have a macro that goes through an entire workbook and
| replaces every instance of NOW() with the current date -
| 1 year. I recorded the macro and received some help on
| the proper syntax for replacing with the year old date.
| After using the code I ran the macro and it worked. I
| then created a button and copied the code into it and
| that worked fine as well.
|
| After making multiple copies and running the macro and
| button repeatedly I copied the workbook onto my network
| and asked someone else to test it. This failed so I
| copied the file back to my hard drive and got it to
| running again by running the replace manually. After the
| manual run I started copying back new copies from the
| network again and they ran fine. Another copy saved to
| the network stopped working again.
|
| Any ideas why this is happening?
|
| Sheets("Vac&Sick").Select
| Range("K1").Select
| Cells.Replace What:="NOW()", Replacement:="date(" &
| Year(Date) - 1 & ",12, 31)", LookAt:= _
| xlPart, SearchOrder:=xlByRows, MatchCase:=False,
| SearchFormat:=False, _
| ReplaceFormat:=False
| Application.CutCopyMode = False
| Range("B2").Select
| ActiveWorkbook.Save
|
| LWhite




All times are GMT +1. The time now is 02:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com