Nested IF, CountIF Syntax errors using last row

johnnyb5

Board Regular
Joined
Dec 23, 2014
Messages
89
The formula below is in a lengthy macro and it worked fine when the nested countif range uses numbers, i.e. countif(P6:P1000); I need a dynamic range however, and I've been trying to replace the range numbers with different versions of " & LstRw " but all I get is syntax errors. I assume I'm not using the quotation marks correctly somehow but I have tried about a thousand different versions so far without any luck.

<<Range("D1").Select
<< Selection.Formula = "=If(Countif(P6:P "" & LstRw & "" ,""W1D4*""),""ORDNANCE SCHOOL CURRENT FY CLIX"",If(CountIf(P6:P "" & LstRw & "" ,""W0G4*""),""165TH INF BDE CURRENT FY CLIX"", """"))"

If anyone could assist with the correct syntax to use the dynamic "& LstRw" in the nested countif it would be great.

Thanks,
JB
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Perfect!!!
Thanks for coming to the rescue, looks like I had to change the quotes and the spaces.
JB
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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