Formula calculation dependent on drop down list

Lil Stinker

Board Regular
Joined
Feb 16, 2022
Messages
151
Office Version
  1. 2019
Platform
  1. Windows
I know it must be possible to have two different formulas calculate in the same cell based on the result chosen from a drop down list but I can't seem to make it work. I have a form where I need the subtotal to calculate for monthly prorating or weekly prorating between a start and end date differently based on whether the user is selecting "Months" or "Weeks" from the drop down.

The way these totals are reached for the monthly proration is somewhat convoluted. In order to receive accurate proration, I have to break it out in hidden columns off from the main table. For the weekly prorating, it is simply a matter of multiplying the unit rate*weekly term*quantity from the main table. Note, the E column only produces a decimal value when "Weeks" is chosen by design. Due to the convoluted monthly calculations, it is easier to have the E column show a simplified, common language breakout since the calculations are handled in the background.

I tried to use an IF statement but it only results in #VALUE for reasons beyond my understanding.
IF(E$1="Months",(D3*H8+K8*I8+L8*J8)*C3),IF(E$1="Weeks",(D3*E3*C3))

ORDER FORM -formula tests- 2022.xlsx
ABCDEFGHIJKLM
1DescriptionQTYUnit RateWeeksItem Subtotal[ Term ]
2Pickup DateWiFi Router2200.001.71$171.40Months
312/29/22MiFi Hotspot1100.001.71#VALUE!Weeks
4Billing Start
502/24/22
6Billing EndMonthsWeeksDaysWeekly RateDaily RateSubtotal
703/08/220.001.005.0050.007.14171.40
8Return Date0.001.005.0025.003.5742.85
904/01/22      
10      
11Subtotal#VALUE!      
12Discount$0.00      
13Net Amount#VALUE!      
14TOTAL AMOUNT#VALUE!      
Sheet2
Cell Formulas
RangeFormula
E2:E3E2=IF(E$1="Weeks",ROUNDDOWN((DATEDIF($A$5,$A$7,"d")/7),2),IF(OR($B2="",AND(E$1<>"Months")),"",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(IF(E$1="Months",DATEDIF($A$5,$A$7,"m")&"m,"&INT(($A$7-EDATE($A$5,DATEDIF($A$5,$A$7,"m")))/7)&"w,"&MOD($A$7-EDATE($A$5,DATEDIF($A$5,$A$7,"m")),7)&"d",INT(($A$7-$A$5)/7)&"w,"&MOD($A$7-$A$5,7)&"d"),"0m,",""),"0w,",""),",0d","")))
F2F2=IF(ISBLANK(C2),"",(D2*H7+K7*I7+L7*J7)*C2)
F3F3=IF(E$1="Months",(D3*H8+K8*I8+L8*J8)*C3),IF(E$1="Weeks",(D3*E3*C3))
H7:H14H7=IF(ISBLANK(C2),"",DATEDIF($A$5,$A$7,"M"))
I7:I14I7=IF(ISBLANK(C2),"",INT(($A$7-EDATE($A$5,DATEDIF($A$5,$A$7,"m")))/7))
J7:J14J7=IF(ISBLANK(C2),"",MOD($A$7-EDATE($A$5,DATEDIF($A$5,$A$7,"m")),7))
K7:K14K7=IF(ISBLANK(C2),"",(ROUND(D2/4,2)))
L7:L14L7=IF(ISBLANK(C2),"",(ROUND(K7/7,2)))
M7:M14M7=IF(ISBLANK(C2),"",(D2*H7+K7*I7+L7*J7)*C2)
F11F11=SUBTOTAL(109,Table22[Item Subtotal])
F13F13=(F11-(F11*F12))
F14F14=F13
Cells with Data Validation
CellAllowCriteria
E1List=$H$1:$H$3
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
F3: =IF(E$1="Months",(D3*H8+K8*I8+L8*J8)*C3,IF(E$1="Weeks",D3*E3*C3))

(Your formula close the first IF() too early)
 
Upvote 0
Solution

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