# Microsoft Office Application Help - Excel Help forum > Excel General >  >  Excel VBA - Range variable

## Davew01

I am fairly new to Excel macro programming and need some help. I am trying to set up a variable as an object type to store a range. I know the following works

Dim rMyCell As Range
Set rMyCell = Range("A1")
rMyCell = rMyCell + Range("a2")
where as rMyCell will = the contents of cell A1 which I then add to cell A2.

What I would like to do is set the range to the activecell in the spreadsheet.
I tried to code below by I get an error.

Dim rMyCell As Range
Set rMyCell = ActiveCell.Select

I also tried this and still get an error.

Set rMyCell = Worksheets("Notes").ActiveCell.Select


Davew01

----------


## duane

I don't know if this will help but you can certainly do somethinglike this

myrow = ActiveCell.Row
mycol = ActiveCell.Column
Cells(myrow, mycol) = cells(myrow,mycol)+range("a2").value

----------


## duane

or, more simply.....

ActiveCell.Value = ActiveCell.Value + Range("a2").Value

----------


## Davew01

Thanks Duane, let me give those two options a try. I appreciate the quick response.

Davew01

----------


## mudraker

You can also try

Dim rMyCell As Range
Set rMyCell = ActiveCell

----------


## ExcelIsEasy

Maybe someone will need tutorial: VBA Range

----------

