BBlu
asked on
Excel VBA: using variables in Range object
Is there a way in the attached code to replace the a1 style cell reference for the range object with variables?
Sub AddOneSum()
Dim n As Integer
Dim RanngeToAdd As Range
Dim RangeSum As Integer
Dim LowerRange As String
Dim UpperRange As String
n = 1
LowerRange = "e1"
UpperRange = "e22"
RangeSum = 0
Set RangeToAdd = ActiveSheet.Range("e1:e11")
For Each Cell In RangeToAdd
Cell.Value = n
n = n + 1
RangeSum = RangeSum + Cell.Value
Next
Range("g12").Value = RangeSum
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect! I tried something similar, but thought I had to include the quotes. Thanks.
=OFFSET($A$1,0,0,COUNT($A: