跳到主要内容

如何在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 快速将绝对引用更改为相对引用

Kutools for Excel: 带有超过100个方便的Excel加载项,可以在30天内免费试用。 立即获取

Kutools for Excel 让您快速,轻松地将绝对值更改为相对参考值,反之亦然。 请执行以下操作:

步骤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 Tab 为 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