Unable to set the formulaarray property of the range class

MrNameless

New Member
Joined
Nov 21, 2018
Messages
2
Hi Gurus,

I'm new in VBA and I do need some help for the following codes.
In Excel file, my code works fine but not in VBA.

In Excel file, my codes are as follows:

=IF(E2="","Not Found", IF(COUNTIFS(E:E,E2,F:F,F2)>1, IF(COUNTIFS(E$1:E2,E2,F$1:F2,F2)=1, SUMIFS('Traffic Report'!$L:$L,'Traffic Report'!$J:$J,"*"&F2&"*",'Traffic Report'!$K:$K,"*"&E2&"*"),"Duplicate"), IF(COUNTIFS('Traffic Report'!$J:$J,"*"&F2&"*", 'Traffic Report'!$K:$K,"*"&E2&"*")>0, SUMIFS('Traffic Report'!$L:$L,'Traffic Report'!$J:$J,"*"&F2&"*",'Traffic Report'!$K:$K,"*"&E2&"*"), "Not Found")))

When its converted into VBA, it became

Range("W2").Select
Selection.FormulaArray = _
"=IF(RC[-18]="""",""Not Found"", IF(COUNTIFS(C[-18],RC[-18],C[-17],RC[-17])>1, IF(COUNTIFS(R1C[-18]:RC[-18],RC[-18],R1C[-17]:RC[-17],RC[-17])=1, SUMIFS('Traffic Report'!C12,'Traffic Report'!C10,""*""&RC[-17]&""*"",'Traffic Report'!C11,""*""&RC[-18]&""*""),""Duplicate""), IF(COUNTIFS('Traffic Report'!C10,""*""&RC[-17]&""*"", 'Traffic Report'!C11,""*""&RC[-18]&""*"")>0" & _
", SUMIFS('Traffic Report'!C12,'Traffic Report'!C10,""*""&RC[-17]&""*"",'Traffic Report'!C11,""*""&RC[-18]&""*""), ""Not Found"")))" & _
""

I'm having error as my code is unable to set the formulaarray property of the range class.
Please help..
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Welcome to the forum.

I can't see why that would need to be an array formula, so you could just try this:

Code:
Range("W2").FormulaR1C1 = _
"=IF(RC[-18]="""",""Not Found"", IF(COUNTIFS(C[-18],RC[-18],C[-17],RC[-17])>1, IF(COUNTIFS(R1C[-18]:RC[-18],RC[-18],R1C[-17]:RC[-17],RC[-17])=1, SUMIFS('Traffic Report'!C12,'Traffic Report'!C10,""*""&RC[-17]&""*"",'Traffic Report'!C11,""*""&RC[-18]&""*""),""Duplicate""), IF(COUNTIFS('Traffic Report'!C10,""*""&RC[-17]&""*"", 'Traffic Report'!C11,""*""&RC[-18]&""*"")>0" & _
", SUMIFS('Traffic Report'!C12,'Traffic Report'!C10,""*""&RC[-17]&""*"",'Traffic Report'!C11,""*""&RC[-18]&""*""), ""Not Found"")))"
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,398
Messages
6,124,699
Members
449,180
Latest member
craigus51286

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