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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
16,545
Office Version
  1. 2013
Platform
  1. Windows
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

nmgmarques

Board Regular
Joined
Mar 1, 2011
Messages
133
Office Version
  1. 365
Platform
  1. Windows
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,195,640
Messages
6,010,871
Members
441,571
Latest member
stolenweasel

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
Top