Reputation: 475
I'm doing my first Excel VBA project and am having some trouble. I'd like to get the value in a cell in the CurrentBalance column. I'll be using ActiveCell.Row to get the row number. 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
I've been trying things for an hour and can't get it to work. I've tried Range and Cell and othe things. Suggestions?
Upvotes: 1
Views: 10919
Reputation: 35990
CurrentBalance is a named range.
Sub test()
Dim BalanceVariable As Double
BalanceVariable = Cells(ActiveCell.Row, Range("CurrentBalance").Column)
MsgBox "the current balance is " & BalanceVariable
End Sub
Upvotes: 4