Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clearing indirect references

Status
Not open for further replies.

NOEd

Coastal
May 14, 2003
7
0
0
US
It can be a nusiance to copy eqns from cell to cell so this sometimes helps:
'Changes a cell to read the same as the cell it's refering to
Sub ClearIndirectRef()
With Selection
FRow = .Row
RowCt = .Rows.Count
LRow = FRow + RowCt - 1
FCol = .Column
ColCt = .Columns.Count
LCol = FCol + ColCt - 1
End With

If RowCt > 3 Or ColCt > 3 Then
a = MsgBox("Are you sure?", 1, "More than 3 rows selected")
If a = vbCancel Then Exit Sub
End If

For r = FRow To LRow
For c = FCol To LCol
Cells(r, c).Activate
t1 = Cells(r, c).Formula
If Len(t1) > 1 Then
If left(t1, 1) = "=" Then
a = Mid(t1, 2)
If Len(a) > 1 Then
t2 = Range(a).Formula
Cells(r, c).Formula = t2
End If
End If
End If
Next
Next
End Sub
 
Status
Not open for further replies.
Back
Top