计算后查看单元格地址

时间:2018-04-29 21:26:06

标签: excel-formula

我已经构建了如下宏,它运行良好。但是,我有一个问题。我想看看每个单元格中的计算是如何执行的,例如在" $ B $ 6 + A6"原始excel文件中的格式,但我无法这样做。如果你可以帮我解决这个问题真的很好。

非常感谢

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

1 个答案:

答案 0 :(得分:2)

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

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"