# (urgent:)VBA coding.....Selection.Formula

#### alfee

##### New Member
I am appreciated if there is someone out there can give me a hand on this!

I am trying to write an VBA in excel; here is the coding:

Sheet1.Cells(5, 5).Select *it will bring me to the cell E5
Selection.Formula = "=A1" *it will enter a formula: "=A1" in the E5

My question is how can I enter a coding like above in cell E5 which gives me an addition of E4 and D5 (ie. to add the cell above my starting postion and the cell on the left). But the command: Selection.Formula="=E4+D5" could not help as I need the formula to be using 'relative address (ie. adding the cell above me and the cell on my left)'' instead of "absolute address (ie. E4+D5)" so that I can use the command on other cell.

Last edited:

### Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

#### Colin Legg

##### MrExcel MVP
Hi alfee,

See if this works for you:

Code:
`` Sheet1.Cells(5, 5).FormulaR1C1 = "=R[-1]C+RC[-1]"``

#### alfee

##### New Member
Hi alfee,

See if this works for you:

Code:
`` Sheet1.Cells(5, 5).FormulaR1C1 = "=R[-1]C+RC[-1]"``

Colin, it works and as I wanted! I was so nervious and worry about the above problem...thank you!

Alf

Replies
5
Views
226
Replies
5
Views
140
Replies
2
Views
179
Replies
5
Views
163
Replies
0
Views
297

1,191,371
Messages
5,986,264
Members
440,015
Latest member
knijgh

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back