Macro stops running after file has moved

  • Thread starter Thread starter LWhite
  • Start date Start date
L

LWhite

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
 
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
| 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top