changing a cell reference

I

I Maycotte

Hi everyone. I am hoping someone is willing to help. I would like to
to test if a cell containing, a cell reference (eg, f(x) = Sheet2!A1),
grabs a value from a particular sheet (in this case Sheet2). If this
is the case, I want to change the sheet which it pulls a value from
(say Sheet1). My question is how do I (a) test this condition and (b)
edit the formula so it references a different sheet?

Here is my code thus far:

Sub ChangeRef()
Dim ws As Worksheet
Dim ReplaceWith As String
Dim ref As String

ref = Left("=#REF", 5)
ReplaceWith = "=Autofilter"

For Each ws In ActiveWorkbook.Worksheets
ws.Activate
For Each cell In ActiveSheet.UsedRange.Cells
'' If cell formula contains #REF! Then replace with
Autofilter!
cell = WorksheetFunction.Replace(ref, 1, 10, ReplaceWith)
'' End If
Next cell
Next ws
End Sub

Thank you to anyone that can help me.

-- Isaac M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top