VBA code for Trace Precedents

aayaanmayank

Board Regular
Joined
Jul 20, 2018
Messages
149
Hi All, below code is working on Active cell. however i want this code to run on entire worksheet.

Code:
Sub MyTracer()Dim rngTrace As Range
Set rngTrace = Range("xx" & Rows.Count)


Dim CheckPrecedents As Variant
On Error Resume Next
CheckPrecedents = ActiveCell.Precedents
If Err Then Exit Sub


With ActiveCell
    If rngTrace.Value = 1 Then
        .ShowPrecedents Remove:=True
        rngTrace.Value = 0
    Else
        .ShowPrecedents
        rngTrace.Value = 1
    End If
End With
End Sub
 

Some videos you may like

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

James006

Well-known Member
Joined
Apr 4, 2009
Messages
3,680
Hello,

A couple of quick remarks ...

Your idea could lead you to exactly the opposite of what you are looking for ... with an extremely crowded screen ...

If you really want to handle the whole worksheet ... what is preventing you from inserting a loop ?

HTH
 

Watch MrExcel Video

Forum statistics

Threads
1,109,308
Messages
5,527,930
Members
409,793
Latest member
mavrik_stet

This Week's Hot Topics

Top