[英]Get cell value using named range in Excel VBA
I'm doing my first Excel VBA project and am having some trouble. 我正在做我的第一个Excel VBA项目,遇到了一些麻烦。 I'd like to get the value in a cell in the CurrentBalance column.
我想在CurrentBalance列的单元格中获取值。 I'll be using ActiveCell.Row to get the row number.
我将使用ActiveCell.Row获取行号。 And I'd like to use a named range for the column in case I need to insert additional columns later.
而且我想为该列使用命名范围,以防以后需要插入其他列。
So what I'd like to have is: BalanceVariable = "CurrentBalance"$ActiveCell.Row 所以我想拥有的是:BalanceVariable =“ CurrentBalance” $ ActiveCell.Row
I've been trying things for an hour and can't get it to work. 我已经尝试了一个小时,却无法正常工作。 I've tried Range and Cell and othe things.
我已经尝试过Range和Cell等东西。 Suggestions?
有什么建议吗?
CurrentBalance is a named range. CurrentBalance是一个命名范围。
Sub test()
Dim BalanceVariable As Double
BalanceVariable = Cells(ActiveCell.Row, Range("CurrentBalance").Column)
MsgBox "the current balance is " & BalanceVariable
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.