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 ?

COLUMN DCOLUMN E
FRUITBUCKETS
APPLEFRUIT BUCKET
BANANAFRUIT BUCKET
BEANVEGGIE BUCKET
CARROTVEGGIE BUCKET

<tbody>
</tbody>

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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
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,215,339
Messages
6,124,362
Members
449,155
Latest member
ravioli44

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