简体   繁体   English

Excel公式过于复杂

[英]Excel Formula overly complex

I have a formula that builds a string with If statements, CONCATENATE, and text formulas. 我有一个使用If语句,CONCATENATE和文本公式构建字符串的公式。 My problem is that the formula's getting extremely larger than I ever wanted it. 我的问题是该公式变得比我想要的要大得多。

My formula first looks to see if a cell if blank 我的公式首先查看是否一个单元格为空

=IF(I3="","",Else)

The Second part is to check if the letters "DKB" is in the H cell 第二部分是检查字母“ DKB”是否在H单元中

=IF(ISNUMBER(SEARCH("*DKB*",$H3)),True,False)

The Third is if the duration (Cell F) has 0 hrs do not include (HH) 第三是持续时间(单元格F)有0小时不包括(HH)

=IF(TEXT(F3,"HH")<>"00",CONCATENATE(TEXT(F3,"hh\h\r mm\m\i\n"),CONCATENATE(TEXT(F3,"mm\m\i\n"))

The Fourth one is if the are 0 min don't include min selection 第四个是如果0分钟不包括分钟选择

=IF(TEXT(F3,"MM")<>"00",CONCATENATE(Text(F3,"HH:MM")),CONCATENATE(Text(F3,"HH"))

If I were to write all the ways this could get played out I would have a total of 10 IF's. 如果我用所有的方式来写,那我将总共有10个IF。 I want a simple way to write for each option without having to write out each answer. 我想要一种简单的方法来为每个选项编写,而不必写下每个答案。 I have a partial code but doesn't include the minute portion. 我有一个部分代码,但不包括分钟部分。 Is there a better way to do this? 有一个更好的方法吗? as you can see me using only if statements I'm not an expert. 如您所见,仅当我不是专家时才使用我。

Here's a picture to demonstrate my sample data and sample output 这是一张展示我的示例数据和示例输出的图片 在此处输入图片说明

If we could have a variable for the first part ie:10-17 to 9:10 PM 如果第一部分可以有一个变量,即:10-17到9:10 PM

2nd variable for duration 持续时间的第二个变量

3rd variable for DKB DKB的第三个变量

Would this be possible 这可能吗

您可能正在寻找这样的东西:

=IF(I3="","",TEXT(A3,"mm-dd-yyyy")&" On-Site "&TEXT(E3,"hh:mm AM/PM")& "- "&TEXT(G3,"hh:mm AM/PM")&" "&TEXT(F3,"hh\h\r mm\m\i\n")&IF(COUNTIF(H3,"*DKB*"),MID(H3,4,20),""))
=IF(I3="","",TEXT(A3,"mm-dd-yyyy")&" On-Site "&TEXT(E3,"hh:mm AM/PM")&"- "&TEXT(G3,"hh:mm AM/PM")&" "&IF(COUNTIF(F3,"*:00:*"),TEXT(F3,"hh\h\r"),IF(COUNTIF(F3,"00:*:*"),TEXT(F3,"mm\m\i\n"),TEXT(F3,"hh\h\r mm\m\i\n"))&IF(COUNTIF(H3,"*DKB*"),MID(H3,4,20),""))))

这将使它不会显示00hr或00min

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

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