如何在Excel工作表中檢查超連結是否存在?
如果我們擁有大量資料,其中超連結散佈在整個工作表中,那麼查詢超連結和外部引用就會成為一項繁瑣的任務。本教程將幫助使用者在以下場景中查詢工作表中可用的超連結:
查詢Excel中的所有超連結
查詢連結到特定文字的所有超連結
使用VBA程式碼查詢所有超連結位置
查詢Excel中的所有超連結
步驟1 - 下面顯示了一個示例工作表,其中包含散佈的超連結。
步驟2 - 請注意,使用查詢和替換功能,可以輕鬆識別所有超連結。為此,請按鍵盤上的Ctrl+H鍵。查詢和替換對話方塊將開啟。
或者,您可以按照以下路徑開啟它:
Home > Editing > Find & Select > Replace
步驟3 - 在“查詢和替換”對話方塊上,單擊選項。
步驟4 - 對話方塊將如下展開。轉到查詢內容旁邊的格式,然後單擊向下箭頭以選擇從單元格選擇格式。
步驟5 - 從包含超連結的工作表中選擇一個單元格。然後將顯示單元格資料的預覽,如下所示。現在單擊對話方塊底部的全部查詢按鈕。
步驟6 - 它將以列表形式顯示所有包含超連結的單元格,如下所示。您可以單獨選擇每個單元格,也可以按住Ctrl鍵從列表中選擇多個單元格。
查詢Excel中連結到特定文字的所有超連結
步驟1 - 顯示一個示例工作表,其中包含一些類似的超連結單元格值。
步驟2 - 重複上述方法中的步驟2和3。
步驟3 - 轉到查詢內容旁邊的格式,然後單擊向下箭頭以選擇從單元格選擇格式。現在選擇要搜尋特定文字超連結的單元格。接下來,在“查詢內容”欄位中輸入要查詢的精確單元格值。
步驟4 - 現在單擊對話方塊底部的全部查詢按鈕。它將以列表形式顯示所有包含輸入值的超連結單元格,如下所示。您可以單獨選擇每個單元格,也可以按住Ctrl鍵從列表中選擇多個單元格。
使用VBA程式碼查詢所有超連結位置
步驟1 - 按下鍵盤上的Alt+F11鍵,這將開啟Microsoft Visual Basic for Applications視窗。
步驟2 - 在Microsoft Visual Basic for Applications視窗中,轉到插入>模組。
步驟3 - 現在將以下程式碼貼上到工作區中:
程式碼片段
Sub HyperlinkCells() \ A VBA function used to jump to a location of a worksheet where hyperlinks are available Dim xAdd As String \ Adding a variable xAdd as string type Dim xTxt As String \ Adding a variable as xText as string type Dim xCell As Range \ Adding a variable xCell as Range type Dim xRg As Range \ Adding a variable as xRg as range type. On Error Resume Next \ when a run-time error occurs, go to the statement immediately following the statement where the error occurred and execute next. xTxt = ActiveWindow.RangeSelection.AddressLocal \ Returns a Range object that represents the selected cells on the worksheet in the active window Set xRg = Application.InputBox("Please select range:", "Kutools for Excel", xTxt, , , , , 8) \ A popup message box to display range of cells If xRg Is Nothing Then Exit Sub \ If no hyperlink is found then exit from the sub statement For Each xCell In xRg \ Condition For each xCell variable in the range If xCell.Hyperlinks.Count > 0 Then xAdd = xAdd & xCell.AddressLocal & ", " \ Condition to count the hyperlinked cells in the active sheet Next If xAdd <> "" Then \ If the value of xAdd is Not Equal to firstAddress then execute the next statement. MsgBox "Hyperlink existing in the following cells: " & vbCrLf & vbCrLf & Left(xAdd, Len(xAdd) - 1), vbInformation, "Kutools for Excel" \ Display a msg box with all hyperlinked cell addresses.) End If \ end if condition End Sub \ end sub statement
步驟4 - 現在,按F5執行程式碼。將開啟一個Excel Kutools對話方塊。
步驟5 - 現在選擇要在其中搜索超連結的資料集範圍,然後單擊“確定”按鈕。
步驟6 - 然後將開啟一個對話方塊,顯示包含超連結的單元格位置。
結論
因此,在本文中,我們學習了三種在Excel電子表格中查詢超連結的方法。在海量資料中查詢超連結是一項繁瑣的任務。有時我們需要為了參考或資料共享的目的整合它們。VBA程式碼方法實際上還可以找到所有隱藏的超連結,這些超連結沒有特殊的格式。
希望本文能幫助您學習Excel的新技巧。繼續探索,繼續學習。