VBA code to find/replace #ref in formula

WWII_Buff

Board Regular
Joined
Nov 13, 2017
Messages
88
I have searched high and low. Is there a way to find several #REF ! in a formula string within a range (B11:AP55) in a single worksheet and replace it with a "Master".

Code:
=SUMIFS(INDEX([URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=REF]#REF[/URL] !,0,MATCH('SITE'!AP$3,[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=REF]#REF[/URL] !,0)),[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=REF]#REF[/URL] !,'SITE'!$A11,[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=REF]#REF[/URL] !,'SITE'!$A$45)
 
I ran it on a small sample of data and it worked as expected. My code shouldn't have generated that error as it doesn't use any data types. Which line of code is highlighted when you go into the debugger?
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
I will take another look if you confirm it should have worked in the example I provided.

Code:
.Formula = Replace(.Formula, "#REF", "Master", , , vbTextCompare)
 
Last edited:
Upvote 0
I am calling back on this thread.

I have sheet within a workbook that provides details [detail] once a selection from a drop down is created on another sheet [selection]. I also have this massive MACRO I run when I need to update the entire workbook. This MACRO deletes and re-creates a tab called [consolidated]. The [detail] tab has many formulas based from the [consolidated] tab...however, when that tab is deleted, and re-created with new data; the formulas go to "#REF!" instead of "consolidated!". I tried so many things and cant get anything to work. How do I search in the entire [detail] tab and replace ALL of the #REFs with consolidated in ALL formulas?
 
Upvote 0
Actually,

Is there a way to lock in the formulas on the [detail] tab instead of find/replace once the deletion and re-creations of the [consolidation] tab happens? Because not only does the #REF happen; it also removes my ranges. e.g. "consolindated!A:A" turns to "#REF !". So I need the "consolidated" tab name, but also keep my reference cells.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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