Dynamic Formula

imback2nite

Board Regular
Joined
Oct 30, 2004
Messages
203
Office Version
  1. 2003 or older
Platform
  1. Windows
This is probably an easy one; I’m just not seeing it.

I’m using this formula. It works but I want to make it so the “Emp1” can be changed from “Emp1” thru “Emp30”.
I have a drop down where the selection will be from Emp1, Emp2 etc. to Emp30. The entire formulas parameters would stay the same as seen below. Just the Emp page reference would change.
If this can happen, it will drop the number of formulas’ on the page from 210 to 7 and greatly speed the workbook.
I’m using Windows and Excel v.2003

Rich (BB code):
=IF('Personal Graphs'!$P$2='Personal Graphs'!$Q$9,COUNTIF(Emp1!$B$12:$C$85,'Personal Graphs'!$P$2)+COUNTIF(Emp1!$Q$12:$R$85,'Personal Graphs'!$P$2)+COUNTIF(Emp1!$AF$12:$AG$85,'Personal Graphs'!$P$2)+COUNTIF(Emp1!$B$12:$C$85,'Personal Graphs'!$Q$10)+COUNTIF(Emp1!$Q$12:$R$85,'Personal Graphs'!$Q$10)+COUNTIF(Emp1!$AF$12:$AG$85,'Personal Graphs'!$Q$10),COUNTIF(Emp1!$B$12:$C$85,'Personal Graphs'!$P$2)+COUNTIF(Emp1!$Q$12:$R$85,'Personal Graphs'!$P$2)+COUNTIF(Emp1!$AF$12:$AG$85,'Personal Graphs'!$P$2))



=IF('Personal Graphs'!$P$2='Personal Graphs'!$Q$9,COUNTIF(Emp2!$B$12:$C$85,'Personal Graphs'!$P$2)+COUNTIF(Emp2!$Q$12:$R$85,'Personal Graphs'!$P$2)+COUNTIF(Emp2!$AF$12:$AG$85,'Personal Graphs'!$P$2)+COUNTIF(Emp2!$B$12:$C$85,'Personal Graphs'!$Q$10)+COUNTIF(Emp2!$Q$12:$R$85,'Personal Graphs'!$Q$10)+COUNTIF(Emp2!$AF$12:$AG$85,'Personal Graphs'!$Q$10),COUNTIF(Emp2!$B$12:$C$85,'Personal Graphs'!$P$2)+COUNTIF(Emp2!$Q$12:$R$85,'Personal Graphs'!$P$2)+COUNTIF(Emp2!$AF$12:$AG$85,'Personal Graphs'!$P$2))
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Firstly, your original formula ..
Excel Formula:
=IF('Personal Graphs'!$P$2='Personal Graphs'!$Q$9,COUNTIF('Emp1'!$B$12:$C$85,'Personal Graphs'!$P$2)+COUNTIF('Emp1'!$Q$12:$R$85,'Personal Graphs'!$P$2)+COUNTIF('Emp1'!$AF$12:$AG$85,'Personal Graphs'!$P$2)+COUNTIF('Emp1'!$B$12:$C$85,'Personal Graphs'!$Q$10)+COUNTIF('Emp1'!$Q$12:$R$85,'Personal Graphs'!$Q$10)+COUNTIF('Emp1'!$AF$12:$AG$85,'Personal Graphs'!$Q$10),COUNTIF('Emp1'!$B$12:$C$85,'Personal Graphs'!$P$2)+COUNTIF('Emp1'!$Q$12:$R$85,'Personal Graphs'!$P$2)+COUNTIF('Emp1'!$AF$12:$AG$85,'Personal Graphs'!$P$2))

.. can be written a bit shorter like this:
Excel Formula:
=COUNTIF('Emp1'!$B$12:$C$85,'Personal Graphs'!$P$2)+COUNTIF('Emp1'!$Q$12:$R$85,'Personal Graphs'!$P$2)+COUNTIF('Emp1'!$AF$12:$AG$85,'Personal Graphs'!$P$2)+IF('Personal Graphs'!$P$2='Personal Graphs'!$Q$9,COUNTIF('Emp1'!$B$12:$C$85,'Personal Graphs'!$Q$10)+COUNTIF('Emp1'!$Q$12:$R$85,'Personal Graphs'!$Q$10)+COUNTIF('Emp1'!$AF$12:$AG$85,'Personal Graphs'!$Q$10),0)

I have then modified the second formula above to meet your drop-down choices. You did not say where your drop-down was. My formula assumes that the drop-down is in cell E6.

Excel Formula:
=COUNTIF(INDIRECT("'"&E6&"'!$B$12:$C$85"),'Personal Graphs'!$P$2)+COUNTIF(INDIRECT("'"&E6&"'!$Q$12:$R$85"),'Personal Graphs'!$P$2)+COUNTIF(INDIRECT("'"&E6&"'!$AF$12:$AG$85"),'Personal Graphs'!$P$2)+IF('Personal Graphs'!$P$2='Personal Graphs'!$Q$9,COUNTIF(INDIRECT("'"&E6&"'!$B$12:$C$85"),'Personal Graphs'!$Q$10)+COUNTIF(INDIRECT("'"&E6&"'!$Q$12:$R$85"),'Personal Graphs'!$Q$10)+COUNTIF(INDIRECT("'"&E6&"'!$AF$12:$AG$85"),'Personal Graphs'!$Q$10),0)


If this can happen, it will drop the number of formulas’ on the page from 210 to 7 and greatly speed the workbook.
Whilst the change may drop the number of formulas, it may not speed the workbook.
To achieve the result you wanted, the INDIRECT function had to be employed. That function is a volatile function which, in general, has the opposite effect to speeding up a worksheet. :)

How it affects your workbook will depend on the particular circumstances and use of your workbook so you will just have to test to see what happens in relation to speed. ?
 
Upvote 0
Solution
That works GREAT! I had tried using CONCATENATE. Incorrectly. :sneaky: Thank you so much! As for speed, it didn't really speed the process much but it DID make it easier to read! Thank you!
 
Upvote 0
You're welcome. Thanks for the feedback. :)
 
Upvote 0

Forum statistics

Threads
1,214,970
Messages
6,122,514
Members
449,088
Latest member
RandomExceller01

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