If formula in visual basic applied to Excel

Stevep4

New Member
Joined
Aug 28, 2015
Messages
35
I have code in visual basic that applies a formula all the way down to where the data ends for column D. When I use a vlookup formula, the code works. Below is the code that works:


Sub FillFormula()
Sheets("On Order").Range("Z4:Z" & Sheets("On Order").Range("D" & Rows.Count).End(xlUp).Row).Formula = "=VLOOKUP(V4,Sheet1!$A$1:$D$65000,4,0)"
End Sub

However, when I try to plug in any kind of IF formula, the code doesn't work:

Sub FillFormulaI()
Sheets("On Order").Range("AA4:AA" & Sheets("On Order").Range("D" & Rows.Count).End(xlUp).Row).FormulaR1C1 = "=IF(IFERROR(AB4,"")="","","bulk")"
End Sub

Does anyone know how I can get an if formula to work?

I apologize if I didn't adhere to all the polices for posting. First time in years posting a question here.

Thanks!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
You need to use double quote marks inside an explicit string
Code:
.FormulaR1C1 = "=IF(IFERROR(AB4,"""")="""","""",""bulk"")"
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,945
Messages
6,175,555
Members
452,652
Latest member
eduedu

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