Hi Aaron,
The line which is causing you problems is:
If Cell Like "*data!*" Then
Unless expressed the default property for cells is VALUE. What your
procedue is doing is looking at the value, not the formula underneath.
So
If Cell.formula Like "*data!*" Then
will do the necessary.
Also tighten the search over the UsedRange
.......
On Error Resume Next
For each Cell in sh.UsedRange.SpecialCells(xlCellTypeFormulas)
....
Next Cell
On Error GoTo 0
........
There is no need to test each cell, Excel knows the ones that have. Encase
this loop with Error statements which take care of none being on the sheet.
Regards
Paul
"Aaron Cooper" wrote in message
...
I am trying to run a macro that will change any cell that links to a tab
called data! to an absolute reference. Below is the code that I have
developed with help from others an articles so far, but I cannot figure
out why this does not work. Can anyone out there please help me?
Thanks, this is driving me crazy.
Sub ConvertFormulae()
For Each wb In Workbooks
For Each sh In wb.Worksheets
For Each Cell In sh.UsedRange
If Cell Like "*data!*" Then
Formula1 = Cell.Formula
newformula = Application.ConvertFormula _
(Formula:=MyFormula1, _
fromReferenceStyle:=xlA1, _
toReferenceStyle:=xlA1, _
toAbsolute:=xlAbsolute)
Cell = newformula
End If
Next Cell
Next sh
Next wb
End Sub
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!