Simplify formulas/using VBA to sum data?

arcylix

New Member
Joined
Sep 12, 2021
Messages
5
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I've been stuck on this for a while. I utilize spreadsheets at work for various actions. What I have currently works, but I'm wondering if there is a more efficient way to tackle this problem, whether through VBA or a more concise formula.

On a sheet titled 'Data', you will find the following information.

dtN2ZPpVSA.png


Column C is Doctor Identification Number, D is the doctor's name, E is their maximum morning procedure count and F is their maximum afternoon procedure count. Not pictured is Column A, which displays a count based off information in worksheet 'New':
Excel Formula:
=VLOOKUP(New!$E2, Data!$H$1:$I$6, 2, 1)

This is expanded down all of Column A and generates either a 1 or a 2 based off Columns H and I. I do not like having Column A, and I sincerely hope there is a way to create a macro or eliminate the need for the column. For more information, the data goes into another worksheet 'Bookings'. To get a count of the procedures, I run the following code:
Excel Formula:
=IF(SUMIFS(Data!$A:$A, New!$C:$C, $A2, New!$A:$A, E$1, New!$B:$B, "*a"), SUMIFS(Data!$A:$A, New!$C:$C, $A2, New!$A:$A, E$1, New!$B:$B, "*a"), 0)
. A visual aid:
lR5trhuXfq.png


Notably, the SUMIFs runs in this fashion: Take cell E2. If the date from New!C:C matches A2, the time ends in 'a', and the doctor matches up with E1, then sum the count of procedures from the Data sheet, column A.

Is what I have the most efficient way to handle it, or can I create some function called 'CountProcedures' in VBA that returns the exact same information I need? Thanks in advance for any help!
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Here are mini-tables that I hope I'm doing right to help assist with what I'm seeking help on.

Tracker.xlsm
ABCDE
1DoctorPeriodAppt DatePatientType
212 7:40a09/13/21SmithEGD
312 8:00a09/13/21SmithEGD
412 8:20a09/13/21SmithEN/CO
512 9:00a09/13/21SmithCOLON
612 9:20a09/13/21SmithEN/CO
71210:00a09/13/21SmithEN/CO
81210:30a09/13/21SmithCOLON
91210:45a09/13/21SmithCOLON
101211:00a09/13/21SmithCOLON
111211:15a09/13/21SmithEN/CO
121512:30p09/13/21SmithCOLON
131512:45p09/13/21SmithCOLON
1415 1:00p09/13/21SmithEGD
1515 1:15p09/13/21SmithEGD
1615 1:30p09/13/21SmithCOLON
1715 1:45p09/13/21SmithCOLON
1815 2:00p09/13/21SmithEN/CO
1915 2:30p09/13/21SmithEN/CO
2015 3:00p09/13/21SmithEGD
New


Tracker.xlsm
ABCDEFGHI
1Count8Smith1511COLON1
2112Jones1410EGD1
3115Jackson1611EN/CO2
4218Davis1410Fsig1
5120Gonzalez1511Ebrav1
6222Brown1511PROC1
7225Taylor119
81
91
101
112
121
131
141
151
161
171
182
192
201
Data (2)
Cell Formulas
RangeFormula
A2:A20A2=VLOOKUP(New!$E2, 'Data (2)'!$H$1:$I$6, 2, 1)


Tracker.xlsm
ABCDEFGHIJKLMNOPQR
1Appt Date88121215151818202022222525Total Proc
209/13/21  14  11        25
3SmithJonesJacksonDavisGonzalezBrownTaylor
4151114101611141015111511119
Bookings (2)
Cell Formulas
RangeFormula
A2A2=IFERROR(INDEX(New!$C1:$C298,MATCH(0,COUNTIF($A$1:A1,New!$C1:$C298),0)),"")
C2,E2,G2,I2,K2,M2,O2C2=IF(SUMIFS(Data!$A:$A, New!$C:$C, $A2, New!$A:$A, C$1, New!$B:$B, "*a"), SUMIFS(Data!$A:$A, New!$C:$C, $A2, New!$A:$A, C$1, New!$B:$B, "*a"), 0)
D2,F2,H2,J2,L2,N2,P2D2=IF(SUMIFS(Data!$A:$A, New!$C:$C, $A2, New!$A:$A, D$1, New!$B:$B, "*p"), SUMIFS(Data!$A:$A, New!$C:$C, $A2, New!$A:$A, D$1, New!$B:$B, "*p"), 0)
R2R2=IF(SUM(C2:P2)>0, SUM(C2:P2), "")
Press CTRL+SHIFT+ENTER to enter array formulas.
Named Ranges
NameRefers ToCells
New!_FilterDatabase=New!$A$1:$O$299C2:P2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
P2Cell Value>$P$4textNO
O2Cell Value>$O$4textNO
N2Cell Value>$N$4textNO
M2Cell Value>$M$4textNO
L2Cell Value>$L$4textNO
K2Cell Value>$K$4textNO
J2Cell Value>$J$4textNO
I2Cell Value>$I$4textNO
H2Cell Value>$H$4textNO
F2Cell Value>$F$4textNO
E2Cell Value>$E$4textNO
D2Cell Value>$D$4textNO
C2Cell Value>$C$4textNO
G2Cell Value>$G$4textNO
C2:P2Cell Value=0textNO
 
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