首页 > 解决方案 > 计算后查看单元格地址

问题描述

我已经构建了如下宏,并且运行良好。但是,我对此有疑问。我想看看每个单元格中的计算是如何执行的,例如原始 excel 文件中的“$B$6+A6”格式,但我无法这样做。如果你能帮我解决这个问题,那就太好了。

非常感谢

Sub RCinput()

Dim a As Long
Dim b As Long
Dim c As Long
Dim d As Long
Dim e As Long




 a = InputBox("What is the row number: ")

 b = InputBox("What is the column number: ")

 c = InputBox("What is the last row number: ")

 e = b - 1


For d = a To c

Cells(d, b).Formula = Cells(d, e).Value * 2

Next


End Sub

标签: excel-formula

解决方案


据我所知,您的公式等于值,因此您会收到一个数字。请尝试像这样修改您的代码:

Sub RCinput()

Dim a As Long
Dim b As Long
Dim c As Long
Dim d As Long
Dim e As Long

 a = InputBox("What is the row number: ")

 b = InputBox("What is the column number: ")

 c = InputBox("What is the last row number: ")

 e = b - 1

For d = a To c

Cells(d, b).Formula = "=" & Cells(d, e).Address & "* 2"

Next

End Sub

部分Cells(d, b).Formula = "=" & Cells(d, e).Address & "*2"将放入Cells(d,b)一个公式,例如"=$A$1*2"


推荐阅读