How to use a relative cell reference in a formula line?

ReneZ

New Member
Joined
May 19, 2015
Messages
20
Is there a way to get relative line referances in a formula line that is to be enetered in a cell?

In the below line I would need to get the line numbers in E34 and D34 the same as the (lastrow + 1).

Code:
Range("F" & (lastrow + 1) [COLOR=#0000ff]& ":F"[/COLOR] & (lastrow + 3)).Formula = "=IF(E34=""Yes"",0,D34*$D$10)"

Bit more explanation - I'm entering a formula into a sheet with unknown rows, but the last 8 lines will always be the same (apart from the row number). The only thing that changes is the fixed cell per line - instead of $D$10 it would be $D$11 etc.

Alternatively I could try to copy all lines down with the first formula and then change the $D$10 into $D$11 with a function using 'replace' and 'right'

Appreciate your advise, thanks!

Regards, Rene
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,213,565
Messages
6,114,338
Members
448,569
Latest member
Honeymonster123

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