ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   change links by a macro (https://www.excelbanter.com/excel-programming/309326-change-links-macro.html)

JohnQ[_2_]

change links by a macro
 
I'm using the macro below to change the input file.
I have to do this for 20 spreadsheets which contains 5
similar links each.

The problem is that excel is not been able to locate the
new file and or path.


Sheets.Select

Cells.Select

Selection.Replace What:= _
"H:\2004\[source.XLS]", _
Replacement:= _
"H:\2005\[source.XLS]", LookAt _
:=xlPart, SearchOrder:=xlByRows, MatchCase:=False


Tom Ogilvy

change links by a macro
 
Unless the What string doesn't match entries in the cells, it should work.

Does it work when you do it manually. If so, turn on the macro recorder
while you do it manually and capture the code.


--
Regards,
Tom Ogilvy

"JohnQ" wrote in message
...
I'm using the macro below to change the input file.
I have to do this for 20 spreadsheets which contains 5
similar links each.

The problem is that excel is not been able to locate the
new file and or path.


Sheets.Select

Cells.Select

Selection.Replace What:= _
"H:\2004\[source.XLS]", _
Replacement:= _
"H:\2005\[source.XLS]", LookAt _
:=xlPart, SearchOrder:=xlByRows, MatchCase:=False




Iain King

change links by a macro
 

"JohnQ" wrote in message
...
I'm using the macro below to change the input file.
I have to do this for 20 spreadsheets which contains 5
similar links each.

The problem is that excel is not been able to locate the
new file and or path.


Sheets.Select

Cells.Select

Selection.Replace What:= _
"H:\2004\[source.XLS]", _
Replacement:= _
"H:\2005\[source.XLS]", LookAt _
:=xlPart, SearchOrder:=xlByRows, MatchCase:=False


Not sure exactly what you want here, but a simple way to make changes in
multiple files is as follows:
this code looks through all open workbooks, writing "Hello" in the top left
cell of sheet 1

For each w in Workbooks
w.Sheets(1).Cells(1,1).Value = "Hello"
Next


If you nest your replace calls inside that For loop, it will replace on
every open workbook.

Iain King




All times are GMT +1. The time now is 09:02 AM.

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