Replace a reference for (as of yet) non existing files

nmgmarques

Board Regular
Joined
Mar 1, 2011
Messages
133
Office Version
  1. 365
Platform
  1. Windows
Hi all.

Current file has following formulas in range D2:O8

Column D
Code:
=IF(ISERROR(VLOOKUP($A2;'K:\MD\_data\Fim do Mês\Data\2018\2018-01\MB5L\[MB5L.xlsx]MB5L_Resumo'!$A$1:$H$19;2;FALSE));;VLOOKUP($A2;'K:\MD\_data\Fim do Mês\Data\2018\2018-01\MB5L\[MB5L.xlsx]MB5L_Resumo'!$A$1:$H$19;2;FALSE))
Column E
Code:
=IF(ISERROR(VLOOKUP($A2;'K:\MD\_data\Fim do Mês\Data\2018\2018-02\MB5L\[MB5L.xlsx]MB5L'!$A$1:$H$19;2;FALSE));;VLOOKUP($A2;'K:\MD\_data\Fim do Mês\Data\2018\2018-02\MB5L\[MB5L.xlsx]MB5L'!$A$1:$H$19;2;FALSE))

Column F
Code:
=IF(ISERROR(VLOOKUP($A2;'K:\MD\_data\Fim do Mês\Data\2018\2018-03\MB5L\[MB5L.xlsx]MB5l'!$A$1:$H$19;2;FALSE));;VLOOKUP($A2;'K:\MD\_data\Fim do Mês\Data\2018\2018-03\MB5L\[MB5L.xlsx]MB5l'!$A$1:$H$19;2;FALSE))

And so forth. Each column looks for the file MB5L in a subfolder corresponding to the year and the filename has the year and month in format 20xx_xx

This year, we'll pull data from files using the same naming strategy, in a 2019 subfolder. What I am looking to do is replace the 2018's in the formulas with 2019's. Using the find and replace won't work as it asks me to point to the new file (which doesn't exist yet).

Is there any script I can use to replace all references in the range from 2018 to 2019 without the files actually existing?
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Run this macro:

Code:
Sub Replace2018()
    Application.DisplayAlerts = False
    Cells.Replace What:="\2018\2018", Replacement:="\2019\2019", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
End Sub
 
Upvote 0
Run this macro:

Code:
Sub Replace2018()
    Application.DisplayAlerts = False
    Cells.Replace What:="\2018\2018", Replacement:="\2019\2019", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
End Sub

That did the trick. Thanks!
 
Upvote 0

Forum statistics

Threads
1,215,548
Messages
6,125,468
Members
449,230
Latest member
ASBeard

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top