Finding relative positions method - one works, the other doesn't???

ReneZ

New Member
Joined
May 19, 2015
Messages
20
Hi, I'm trying to fill some cells in a spreadsheet with formulas, as the input can be changed after the routine has run.

The following works:

Range("F34:F" & lastrow).Formula = "=IF(E34=""Yes"",0,D34*$D$9)"

but the below, set up along the same lines, generates an error;

Range(("F" & (lastrow+1)):("F" & (lastrow+3))).Formula = "=IF(E34=""Yes"",0,D34*$D$10)"

I tried isolating some with more parenthesis, but that didn't work either.

In the above form it gives a 'syntax error'. The same line below gives a 'compile error: syntax error'

Range("F" & (lastrow+1):"F" & (lastrow+3)).Formula = "=IF(E34=""Yes"",0,D34*$D$10)"


Could you please advise what I'm doing wrong? I would expect that, as the first is accepted, the second would run as well. Appreciate your help!

Regards, Rene

I'm using Excel 2010
 
Last edited:

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Try

Range("F" & (lastrow + 1) & ":F" & (lastrow + 3)).Formula = "=IF(E34=""Yes"",0,D34*$D$10)"

Hope this helps

M.
 
Upvote 0

Forum statistics

Threads
1,216,172
Messages
6,129,291
Members
449,498
Latest member
Lee_ray

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