简体   繁体   English

如何有条件地选择数学公式来计算 Excel 中的值?

[英]How can I conditionally choose a math formula to calculate a value in Excel?

I am trying to produce an interactive Excel-based calculator to produce time estimates based on a selected Activity type and an input Quantity.我正在尝试生成一个基于 Excel 的交互式计算器,以根据选定的活动类型和输入数量生成时间估计。 Each activity type has its own formula to convert the input quantity into its respective time estimate.每种活动类型都有自己的公式将输入数量转换为其各自的时间估计。 The formulas used are based on the activity type and are either linear equations ( mx+b ) or scalars (e,g, .2, 4, etc) to be performed on the input quantity.使用的公式基于活动类型,并且是要对输入量执行的线性方程 ( mx+b ) 或标量(例如 .2、4 等)。

The way I have approached it has brought me to a dead-end.我接近它的方式把我带到了死胡同。 Below is an image of my attempt.下面是我尝试的图像。 Yellow columns are input, Blue columns are returned values.黄色列是输入,蓝色列是返回值。

Column A uses a drop-down menu for the user to select the Activity type. A 列使用一个下拉菜单,供用户使用 select Activity 类型。 {Reading, Writing, Quiz, Term Paper} Column B uses VLOOKUP to return the appropriate unit. {阅读、写作、测验、学期论文} B 列使用 VLOOKUP 返回适当的单位。 {words, questions} {单词,问题}

Column C prompts for a Quantity of that unit. C 列提示输入该单位的数量。 Column D uses Column A and a VLOOKUP again to identify the appropriate formula to calculate the estimate, given the input quantity.给定输入数量,D 列再次使用 A 列和 VLOOKUP 来确定适当的公式来计算估计值。

Works fine in simple cases of scalars eg =C1*VLOOKUP(A3, ARRAY, 3, FALSE) , but the linear equation has me stuck.在简单的标量情况下工作正常,例如=C1*VLOOKUP(A3, ARRAY, 3, FALSE) ,但线性方程让我卡住了。 I would need to multiply the input value and then subtract from that product.我需要将输入值相乘,然后从该乘积中减去。 In other words, I need to plug in the input value into a VLOOKUP-derived formula.换句话说,我需要将输入值插入到 VLOOKUP 派生的公式中。

enter image description here在此处输入图像描述

Change your set up to have m in one column and b in another:更改您的设置以使m在一列中, b在另一列中:

在此处输入图像描述

then you can use one formula:那么你可以使用一个公式:

=C2*VLOOKUP(A2,F:I,3,FALSE)+VLOOKUP(A2,F:I,4,FALSE)

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Excel VBA中计算公式并将其值放在变量中? 例如我想将x设置为COUNTA(Sheet1!A:A) - How can I calculate a formula in Excel VBA and put its value in a variable? For example I want to set x equal to COUNTA(Sheet1!A:A) 如何动态选择要在公式中引用的Excel工作表? - How do I dynamically choose an excel sheet to reference in a formula? 我需要一个 excel 公式,可以计算补货或轻拍测试量 - I need an excel formula that can calculate the restock or pat test amounts 我可以使用Excel公式来计算一些连续行的总和吗? - Can I use an Excel formula to calculate the sum of some continuous rows? 如何在Microsoft Excel中将一个单元格中的文本作为另一个单元格中的公式计算? - How can I calculate the text in one cell as a formula in another cell in microsoft excel? 如何使用 excel 公式计算 yyyymm 格式的两个日期时间值之间的差异? - How can I calculate the difference between two date time values in the format yyyymm using excel formula? 如何在Excel中有条件地VLOOKUP? - How can I conditionally VLOOKUP in Excel? 如何在Excel中计算DATEDIF公式? - How to Calculate DATEDIF formula in Excel? 在PhpSpreadsheet中创建Excel文件时如何计算公式 - How to calculate formula when I create excel file in PhpSpreadsheet Excel公式有条件求和 - Excel formula to sum conditionally
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM