Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8039397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:33:22+00:00 2026-06-05T03:33:22+00:00

In Excel Ctrl + [ or ] will sometimes directly switch to another sheet

  • 0

In Excel Ctrl+[ or ] will sometimes directly switch to another sheet to show the precedents or dependents in that sheet.

I want that programmatically, because I want to get the precedents (or dependents) of a selection of cells.

Range.Dependents and Range.Precedents have other issues, but the solution there does not solve the extra-sheet issue.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T03:33:24+00:00Added an answer on June 5, 2026 at 3:33 am

    After a fair bit of Googling I found it was solved in 2003.

    But I used the code from here.

    The problem is that Dependents and Precedents are Range properties, which can’t refer to multiple worksheets.

    The solution uses NavigateArrow to locate the cross-sheet ‘dents.

    Here’s my code:

    Option Explicit
    
    Private Sub GetOffSheetDents(ByVal doPrecedents As Boolean)
    
    Dim c As Range
    Dim results As Range
    Dim r As Range
    Dim sheet As Worksheet
    Dim extra As Boolean
    
    For Each c In Application.Intersect(ActiveSheet.UsedRange, Selection)
        Set r = oneCellDependents(c, doPrecedents)
        If Not r Is Nothing Then
            If r.Worksheet Is ActiveSheet Then
                ' skip it
            ElseIf sheet Is Nothing Then
                Set sheet = r.Worksheet
                Include results, r
            ElseIf Not sheet Is r.Worksheet Then
                If Not extra Then
                    extra = True
                    MsgBox "More than one external sheet in " & IIf(doPrecedents, "Precedents", "Dependents") & ". Only displaying first sheet."
                End If
            Else
                Include results, r
            End If
        End If
    Next
    
    If results Is Nothing Then
        Beep
    Else
        results.Worksheet.Activate
        results.Select
    End If
    End Sub
    
    Sub GetOffSheetDependents()
    
    GetOffSheetDents False
    
    End Sub
    
    Sub GetOffSheetPrecedents()
    
    GetOffSheetDents True
    
    End Sub
    
    Private Function Include(ByRef ToUnion As Range, ByVal Value As Range) As Range
    If ToUnion Is Nothing Then
        Set ToUnion = Value
    Else
        Set ToUnion = Application.Union(ToUnion, Value)
    End If
    Set Include = ToUnion
    End Function
    
    Private Function oneCellDependents(ByVal inRange As Range, Optional doPrecedents As Boolean) As Range
    
    Dim inAddress As String, returnSelection As Range
    Dim i As Long, pCount As Long, qCount As Long
    
    If inRange.Cells.Count <> 1 Then Error.Raise 13
    
    Rem remember selection
    Set returnSelection = Selection
    inAddress = fullAddress(inRange)
    
    Application.ScreenUpdating = False
    With inRange
        .ShowPrecedents
        .ShowDependents
        .NavigateArrow doPrecedents, 1
        Do Until fullAddress(ActiveCell) = inAddress
            pCount = pCount + 1
            .NavigateArrow doPrecedents, pCount
            If ActiveSheet.Name <> returnSelection.Parent.Name Then
    
                Do
                    qCount = qCount + 1
                    .NavigateArrow doPrecedents, pCount, qCount
                    Include oneCellDependents, Selection
                    On Error Resume Next
                    .NavigateArrow doPrecedents, pCount, qCount + 1
                    If Err.Number <> 0 Then _
                        Exit Do
                    On Error GoTo 0
                Loop
                On Error GoTo 0
                .NavigateArrow doPrecedents, pCount + 1
            Else
                Include oneCellDependents, Selection
                .NavigateArrow doPrecedents, pCount + 1
            End If
        Loop
        .Parent.ClearArrows
    End With
    
    Rem return selection to where it was
    With returnSelection
        .Parent.Activate
        .Select
    End With
    Application.ScreenUpdating = True
    
    End Function
    
    Private Function fullAddress(inRange As Range) As String
    With inRange
        fullAddress = .Parent.Name & "!" & .Address
    End With
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Excel sheet has multiple used ranges. I want to copy each range value
My excel sheet contains many columns and many rows. I want the program to
When Excel determines the axis values it will use to represent your data in
Excel has a lookup function that finds a specified value in a row or
In Excel Formulas there are so many different functions, that I am not sure
In Excel we have the VLOOKUP function that looks for a value in a
In excel vba I have added a commandbutton to userform... like below Set ctrl
Excel 2002 VBA. I have a macro that launches an external script whenever a
Excel Sheet data Eno EName Pincode 1 aaa 123456 2 bbb 123423 3 ccc
Excel is telling me that there is unreadable data, and so after I say

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.