# Short version of a formula?

#### F4TMAN

##### New Member
Hello, I'm looking for the possibility of shortening the formula i currently have its really slowing down my excel and takes a long time to load.

Excel Formula:
``=IF(AND(Expense!C2='P&L Month'!\$I\$5,COUNTIFS(Expense!\$C\$2:Expense!C2,Expense!C2,Expense!\$D\$2:Expense!D2,Expense!D2)=1),"YES","")``

keeping in mind that I'm going to drag the formula down to row 5000. Since I'm referencing different tab sheets i was thinking about using name manager not sure if that would help. Any ideas? if you need more information please let me know.

Thank you.

### Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

#### jasonb75

##### Well-known Member
By using 2 IF's instead of AND you can bypass the slower COUNTIFS function when C2 is not a match for \$I\$5.
Excel Formula:
``=IF(Expense!C2='P&L Month'!\$I\$5,IF(COUNTIFS(Expense!\$C\$2:Expense!C2,Expense!C2,Expense!\$D\$2:Expense!D2,Expense!D2)=1,"YES",""),"")``
Other than that, you could try different functions in place of countifs to see if anything is quicker, but to be honest I don't think that using that formula dragged down 5000 rows should be causing too much of a problem.

I set up a test sheet with 5000 rows of random data and it takes 2 seconds to load with your original formula (which will include the time it takes for the test data to randomise).

Replies
6
Views
528
Replies
2
Views
118
Replies
35
Views
773
Replies
25
Views
438
Replies
3
Views
233

1,141,043
Messages
5,703,917
Members
421,321
Latest member
blusky4

### 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.

### Which adblocker are you using?

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

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