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

alfee

New Member
Joined
Mar 5, 2009
Messages
5
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

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi alfee,

See if this works for you:

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

Forum statistics

Threads
1,214,950
Messages
6,122,436
Members
449,083
Latest member
Ava19

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top