简体   繁体   English

为字符分配一个值并在 MS excel 中执行字符串(具有字符)的数学函数(+,-,*,/)

[英]assigned a value to characters and perform a mathematical functions (+,-,*,/) of a string (having characters) in MS excel

I want to perform a sum of a given string ('ABCDEF') based on its pre-assigned values.我想根据给定的预分配值对给定的字符串 ('ABCDEF') 求和。 ie first I want to assign values to each character and then calculate the total value of the string having pre-assigned characters.即首先我想为每个字符分配值,然后计算具有预分配字符的字符串的总值。 Is it possible to carryout this function in excel?是否可以在excel中执行此function? eg.例如。 is below在下面

A=2, B=5, C=8, D=1, E=1, F=2
sum of 'ABCDE'=17
sum of 'FAC'=12

So, this is what I have tried ,所以,这就是我尝试过的,

配方_溶液

• Formula used in cell E1 --> Applicable to Excel 2021 & O365 Users Only • 单元格E1中使用的公式 -->仅适用于 Excel 2021 和 O365 用户

=SUMPRODUCT(VLOOKUP(MID(D1,SEQUENCE(LEN(D1)),1),$A$1:$B$6,2,0))

• Formula used in cell F1 --> Applicable to All Users • 单元格F1中使用的公式 -->适用于所有用户

=SUMPRODUCT(VLOOKUP(MID(D1,ROW(INDIRECT("1:"&LEN(D1))),1),$A$1:$B$6,2,0))

Depending on Excel Version may or may need to press CTRL + SHIFT + ENTER for the above formula!根据 Excel 版本可能或可能需要按CTRL + SHIFT + ENTER以获取上述公式!

The above formula(s) works well when used for one Mathematical Operator, however if you want to use Multiple Operator , then I assume Defining Named Ranges for each of those characters and then use them for Mathematical functions, shall be an easy one!上面的公式在用于一个Mathematical运算符时效果很好,但是如果您想使用多个运算符,那么我假设为每个字符定义命名范围,然后将它们用于Mathematical函数,这应该是一个简单的方法!

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM