跳到主要內容

如何在Excel中將絕對參考更改/轉換為相對參考?

通常,公式中可以使用幾種類型的單元格引用,每種類型的單元格引用都可以幫助您在公式中實現不同的目的。 您可以具有以下類型的單元格引用,例如絕對單元格引用,相對單元格引用,相對行引用,絕對列引用以及絕對行引用和相對列引用。 但是有時您可能需要通過更改公式中的單元格引用來更改公式用途的使用。 以下棘手的方法將告訴您如何在Excel中更改相對引用的絕對引用。

用F4鍵將絕對參考值更改為相對參考值

使用VBA代碼將絕對參考更改為相對參考

使用Kutools for Excel快速將絕對引用更改為相對引用

絕對參考

相對參考


箭頭藍色右氣泡 用F4鍵將絕對參考值更改為相對參考值

使用快捷鍵F4,我們可以輕鬆地將絕對參考切換為相對參考,請執行以下步驟:

將光標放在$ A $ 1後面,然後按三下F4鍵,它將依次變為A $ 1,$ A1,A1。 看截圖:

根據此步驟,將光標置於$ B $ 1後面以獲得B1。

並且該單元格引用將成為絕對引用的相對引用。

如果需要更改多個公式的單元格引用,則此方法將很繁瑣且耗時。


箭頭藍色右氣泡 使用VBA代碼將絕對參考更改為相對參考

使用VBA代碼,您可以一次將一系列公式單元格引用從絕對引用更改為相對引用。

1.選擇要更改的範圍。

2。 點擊 開發者 > Visual Basic中 或者你可以按 Alt + F11鍵,將顯示一個新的Microsoft Visual Basic for Applications窗口,單擊 插入 > 模塊,然後將以下代碼輸入到 模塊:
VBA:將絕對值轉換為相對參考值。

Sub ConverFormulaReferences()
'Updateby20140603
Dim Rng As Range
Dim WorkRng As Range
Dim xName As Name
Dim xIndex As Integer
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Set WorkRng = WorkRng.SpecialCells(xlCellTypeFormulas)
xIndex = Application.InputBox("Change formulas to?" & Chr(13) & Chr(13) _
& "Absolute = 1" & Chr(13) _
& "Row absolute = 2" & Chr(13) _
& "Column absolute = 3" & Chr(13) _
& "Relative = 4", xTitleId, 1, Type:=1)
For Each Rng In WorkRng
    Rng.Formula = Application.ConvertFormula(Rng.Formula, XlReferenceStyle.xlA1, XlReferenceStyle.xlA1, xIndex)
Next
End Sub

3。 然後點擊 文檔-絕對-相對-6 按鈕運行代碼,然後會彈出一個提示框,用於選擇要轉換的範圍,然後單擊“確定”,並顯示另一個對話框,提示您要使用哪種類型。 然後,您可以選擇所需的正確類型。 對於此示例,我將插入4。請參見屏幕截圖:

4。 然後點擊 OK。 選擇中的所有絕對參考已更改為公式中的相對參考。

這是帶有此代碼的多功能VBA代碼; 您還可以相對於絕對參考值更改,更改絕對行或更改絕對列。


箭頭藍色右氣泡 使用Kutools for Excel快速將絕對引用更改為相對引用

Excel的Kutools: 帶有100多個便捷的Excel加載項,可以在30天內免費試用。 立即獲取

Excel的Kutools 讓您快速,輕鬆地將絕對值更改為相對參考值,反之亦然。 請執行以下操作:

步驟1.轉到選擇包含要更改工作表中單元格引用的公式的範圍。

步驟2。 點擊 庫工具 > 轉換參照。 它將顯示 轉換公式參考 對話框。 看截圖:

步驟3。 檢查 相對的 並點擊 Ok or 登記 ,在 轉換公式參考 對話。 它將絕對參考更改為相對參考。

如果要將單元格引用更改為絕對列或絕對行,請檢查 絕對列 選項或 要排絕對 選項。

有關更多詳細信息 轉換參考, 請拜訪 轉換參考功能描述.


相關文章:將相對參考更改為絕對參考

最佳辦公生產力工具

🤖 Kutools 人工智慧助手:基於以下內容徹底改變數據分析: 智慧執行   |  生成代碼  |  建立自訂公式  |  分析數據並產生圖表  |  呼叫 Kutools 函數...
熱門特色: 尋找、突出顯示或識別重複項   |  刪除空白行   |  合併列或儲存格而不遺失數據   |   沒有公式的回合 ...
超級查詢: 多條件VLookup    多值VLookup  |   跨多個工作表的 VLookup   |   模糊查詢 ....
高級下拉列表: 快速建立下拉列表   |  依賴下拉列表   |  多選下拉列表 ....
欄目經理: 新增特定數量的列  |  移動列  |  切換隱藏列的可見性狀態  |  比較範圍和列 ...
特色功能: 網格焦點   |  設計圖   |   大方程式酒吧    工作簿和工作表管理器   |  資源庫 (自動文字)   |  日期選擇器   |  合併工作表   |  加密/解密單元格    按清單發送電子郵件   |  超級濾鏡   |   特殊過濾器 (過濾粗體/斜體/刪除線...)...
前 15 個工具集12 文本 工具 (添加文本, 刪除字符,...)   |   50+ 圖表 類型 (甘特圖,...)   |   40+ 實用 公式 (根據生日計算年齡,...)   |   19 插入 工具 (插入二維碼, 從路徑插入圖片,...)   |   12 轉化 工具 (數字到單詞, 貨幣兌換,...)   |   7 合併與拆分 工具 (高級合併行, 分裂細胞,...)   |   ... 和更多

使用 Kutools for Excel 增強您的 Excel 技能,體驗前所未有的效率。 Kutools for Excel 提供了 300 多種進階功能來提高生產力並節省時間。  點擊此處獲取您最需要的功能...

產品描述


Office選項卡為Office帶來了選項卡式界面,使您的工作更加輕鬆

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 將您的工作效率提高 50%,每天為您減少數百次鼠標點擊!
Comments (7)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Function ConvertMyAddress(strRng As String) As String
Dim rngSelection As Range

Set rngSelection = Application.Range(strRng)
'// Test if empty
If rngSelection Is Nothing Then Exit Function

' MsgBox rngSelection.Address(0, 0) 'A1
' MsgBox rngSelection.Address(1, 0) '$A1
' MsgBox rngSelection.Address(0, 1) 'A$1
' MsgBox rngSelection.Address(1, 1) '$A$1
' MsgBox rngSelection.Address '$A$1
'
' MsgBox rngSelection.Parent.Name & "!" & rngSelection.Address(0, 0)
' MsgBox "[" & rngSelection.Parent.Parent.Name & "]" & rngSelection.Parent.Name & "!" & rngSelection.Address(0, 0)

ConvertMyAddress = rngSelection.Address(1, 1)

End Function
This comment was minimized by the moderator on the site
Wao Excellent teh VBA Code Works Perfect, Thank You very Much
This comment was minimized by the moderator on the site
Excel 2010. I clicked on cancel when the prompt comes up, but excel still ran the script and it froze my computer for several hours. I only had 1 cell highlighted anyway, so even if the script did run, why did it take so long to run? [i realize now that despite pressing cancel, the code ran and made every cell in the worksheet relative ! :( ] I was assigning it to a form button vs pressing play within VBA window. I've used other scripts from KuTools and never experienced this nonsense.
This comment was minimized by the moderator on the site
The F4 toggle works in all versions. but you MUST be in edit mode first. I always press F2 (puts you into edit mode) then F4 to toggle between the four options.
This comment was minimized by the moderator on the site
With the shortcut key F4, we can easily toggle the absolute reference to relative reference, please do //as// the following steps. Forgot to mention F4 didn't work with my excel (windows 7) but your macro and invite to Kutools is great. Sorry about repeat sends, I thought the code wasn't working.
This comment was minimized by the moderator on the site
Thank you very much. Descriptive, easy to follow information.
This comment was minimized by the moderator on the site
Thank you very much, descriptive, easy to follow information.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations