You are on page 1of 1

Sub RemoveSameSheetReferences()

'PURPOSE: Removes Sheet References from formulas when not needed


'SOURCE: www.TheSpreadsheetGuru.com/the-code-vault

Dim sht As Worksheet


Dim fndList As Variant
Dim rplcList As Variant
Dim x As Long

Set sht = ActiveSheet

fndList = Array("'" & sht.Name & "'!", sht.Name & "!")


rplc = ""

'Optimize Code
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

'Loop through each item in Array lists


For x = LBound(fndList) To UBound(fndList)
sht.Cells.Replace What:=fndList(x), Replacement:=rplc, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
Next x

'Optimize Code
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub

You might also like