I currently copy a worksheet that contains workbook and worksheet-specific named ranges. The worksheet-specific references need to be the way they are, the workbook ones need to be hardcoded. I am looking for a way to fixate every named range that contains an external reference.
My current code looks like this, but it's not really what I am after:
Sub HardcodeValuesInExternalNamedRanges(wb As Workbook, ws As Worksheet)
Dim namCur As Name
For Each namCur In wb.Names
If (InStr(1, namCur.RefersTo, ThisWorkbook.Name) > 0) Then
namCur.RefersTo = "=" & ws.Evaluate(namCur.RefersTo)
End If
Next namCur
End Sub
I could not find a way to fixate the values properly. The way it is done now, does the job to some degree but I would prefer if the values were properly converted within the cell and not just on a named range basis.
Another option would be to loop through all cells and see if it contains a named range, but I think this would be too time consuming.
Is there a way to do it more efficiently?