Issue with Formula not following down the column in VBA macro

mDgo0d4mE

New Member
Joined
Oct 9, 2017
Messages
9
Hello,
i have a spreadsheet that i would like to add a column to "E" and name it BUCKETS as the header.
then i want it to copy a formula down from e2 down to lastrow that related to the information in column D

The issue im running into is that the row numbers are not changing in the formula and its putting quotes between the cell name 'D2' making the formula #NAME ?

[TABLE="width: 500"]
<tbody>[TR]
[TD]COLUMN D[/TD]
[TD]COLUMN E[/TD]
[/TR]
[TR]
[TD]FRUIT[/TD]
[TD]BUCKETS[/TD]
[/TR]
[TR]
[TD]APPLE[/TD]
[TD]FRUIT BUCKET[/TD]
[/TR]
[TR]
[TD]BANANA[/TD]
[TD]FRUIT BUCKET[/TD]
[/TR]
[TR]
[TD]BEAN[/TD]
[TD]VEGGIE BUCKET[/TD]
[/TR]
[TR]
[TD]CARROT[/TD]
[TD]VEGGIE BUCKET[/TD]
[/TR]
</tbody>[/TABLE]

any imput would be great, thanks in advance
Code:
Sub test()

Dim x As Long
Dim Rng As Range
Range("E1").EntireColumn.Insert shift:=xlToRight
Range("e1").Value = "BUCKETS"
Set Rng = Range("E2:E" & Range("A2").End(xlDown).Row)
Rng.FormulaR1C1 = "=IF(D2=""APPLE"",""FRUIT BUCKET"",IF(D2=""BANANA"",""FRUIT BUCKET"",IF(D2=""BEAN"",""VEGGIE BUCKET"",IF(D2=""CARROT"",""VEGGIE BUCKET""))))"
End Sub
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
try
Code:
Rng.FormulaR1C1 = "=IF(rc4=""APPLE"",""FRUIT BUCKET"",IF(rc4=""BANANA"",""FRUIT BUCKET"",IF(rc4=""BEAN"",""VEGGIE BUCKET"",IF(rc4=""CARROT"",""VEGGIE BUCKET""))))"
 
Last edited:
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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