Excel 如何在用于/下一步后显示所有结果

Excel 如何在用于/下一步后显示所有结果,excel,vba,Excel,Vba,我想创建一个新的工作表来显示所有单元格都有超链接外包,但在这个工作表中,它只显示最后一个结果,而不是所有结果 Sub test() Application.ScreenUpdating = False Application.EnableEvents = False Dim Ws As Worksheet, Rng As Range Dim r As Long Dim s As Byte On Error Resume Next Application.DisplayAlerts = Fals

我想创建一个新的工作表来显示所有单元格都有超链接外包,但在这个工作表中,它只显示最后一个结果,而不是所有结果

Sub test()
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim Ws As Worksheet, Rng As Range
Dim r As Long
Dim s As Byte

On Error Resume Next
Application.DisplayAlerts = False
Sheets("Hyperlink").Delete
On Error GoTo 0
Sheets.Add Before:=ActiveSheet
ActiveSheet.Name = "Hyperlink"

For Each Ws In Worksheets
r = 1
    For Each Rng In Ws.UsedRange
        If InStr(Rng.FormulaLocal, "[") Then
            Rng.Interior.ColorIndex = 6
            Cells(r, 2).Value = Ws.Name
            Cells(r, 3).Value = Rng.Address
        End If
     Next Rng
r = r + 1
Next Ws
Application.ScreenUpdating = True
Application.EnableEvents = True
MsgBox "Hoan thanh.", , "Nguyen Duc Thinh - 093 23456 19"

End Sub

最好在if语句中增加变量r,而不是在外部

像这样:

For Each Rng In Ws.UsedRange
    If InStr(Rng.FormulaLocal, "[") Then
        Rng.Interior.ColorIndex = 6
        Cells(r, 2).Value = Ws.Name
        Cells(r, 3).Value = Rng.Address
        r = r + 1
    End If
 Next Rng

最好在if语句中增加变量r,而不是在外部

像这样:

For Each Rng In Ws.UsedRange
    If InStr(Rng.FormulaLocal, "[") Then
        Rng.Interior.ColorIndex = 6
        Cells(r, 2).Value = Ws.Name
        Cells(r, 3).Value = Rng.Address
        r = r + 1
    End If
 Next Rng

请注意,如果您关闭它们,则需要再次打开它们或它们永远关闭。请注意,如果您关闭它们,则需要再次打开它们或它们永远关闭。