Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-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
Joined
May 14, 2003
Messages
7
Location
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.

Part and Inventory Search

Sponsor

Back
Top