View Single Post
 
Old 03-21-2024, 03:38 AM
RRB's Avatar
RRB RRB is offline Windows 11 Office 2021
Susan Flamingo
 
Join Date: May 2014
Location: The Holy City of Jerusalem
Posts: 297
RRB is on a distinguished road
Default Macro to navigate to next CR from present location

I have Googled and found nothing. ChatGPT offered me this:


Sub JumpToNextCrossReference()
Dim rng As Range
Dim fld As Field

' Define the range to search for cross-references
Set rng = Selection.Range

' Loop through each field in the document
For Each fld In ActiveDocument.Fields
If fld.Type = wdFieldRef Then
' Check if the field is within the defined range
If fld.Result.InRange(rng) Then
' Select the field and exit the loop
fld.Select
Exit For
End If
End If
Next fld
End Sub

But it is not working and I cannot understand why.

SF
Reply With Quote