#Ref! Error

Guzzlr

Well-known Member
Joined
Apr 20, 2009
Messages
982
Office Version
  1. 2021
Platform
  1. Windows
Hello
I am getting the #Ref! Error because I have a formula in one sheet, that is linked to another sheet that I delete.
When I replace the deleted sheet with an identical sheet with new data, I get the #Ref! error.
How can I retain the formula that is linked to the deleted sheet, when an identical (same column and data only with new data) sheet is placed so the original formula can see it again?
Thank you
 
Use the indirect function within your formulas when linking sheets and ranges. As long as the new sheet has the same name as your old sheet shouldn't cause a #Ref within your formula.
 
Upvote 0

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Use the indirect function within your formulas when linking sheets and ranges. As long as the new sheet has the same name as your old sheet shouldn't cause a #Ref within your formula.
I'm playing around with the indirect function suggested, and it is returning the #Ref! error.

I have:
VBA Code:
=INDIRECT(COUNTIFS('PM Schedule Repair'!$D:$D,Matrix!$B6,'PM Schedule Repair'!$F:$F,Matrix!E$5,'PM Schedule Repair'!$G:$G,Matrix!$D$5))

The count if criteria ranges are correct. I'm not sure if the indirect function will work with CountIfs?
or I'm using it incorrectly.
Thanks for the help
 
Upvote 0
I'd suggest you use code to repopulate the formulas.
My code for CountIfs:

VBA Code:
Option Explicit
Dim Rng As Range

Sub Countifs()

Worksheets("Matrix").Select
With Selection
    Rng("E6").FormulaR1C1 = "=COUNTIFS('PM Schedule Repair'!$D:$D,Matrix!$B6,PM Schedule Repair'!$F:$F,Matrix!E$5,'PMSchedule Repair'!$G:$G,Matrix!$D$5)"
End With

End Sub

However, I am doing something wrong, as I get the below error.
I'm sure it is a simple error...
can you lead me in the right direction
Thank you


1715873471949.png
 
Upvote 0
You didn't assign a range to the Rng variable. Perhaps you meant:

VBA Code:
Worksheets("Matrix").Range("E6").Formula = "=COUNTIFS('PM Schedule Repair'!$D:$D,$B6,PM Schedule Repair'!$F:$F,E$5,'PMSchedule Repair'!$G:$G,$D$5)"
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

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