简体   繁体   English

在Excel If语句中返回一个数字和文本字符串

[英]Return a number and text string in Excel If statement

I am trying to create an If statement in Excel that calculates the difference between two dates (in this case "Required Submission Date" and "Actual Submission Date"), and then outputs the absolute value of this number and follows it with "Days overdue" or "Days until due" accordingly. 我试图在Excel中创建一个If语句来计算两个日期之间的差异(在这种情况下为“必需提交日期”和“实际提交日期”),然后输出此数字的绝对值,并在其后面显示“逾期天数” “或”相应的天数“。

I have attempted converting the number to a text string after the calculation: 我在计算后尝试将数字转换为文本字符串:

=IF((H11-J11)<0,TEXT(H11-J11,0)"Days overdue", TEXT(H11-TODAY(),0)"Days Until Due")

I have also attempted this: 我也试过这个:

=IF((H11-J11)<0,abs(H11-J11)"Days overdue", (abs(H11-TODAY()))"Days Until Due")

Is there any way to achieve what I am after? 有没有办法实现我的目标? ie if the submission is overdue, it should return "XX days overdue" 即如果提交过期,则应返回“XX天逾期”

Thanks 谢谢

You are almost there. 你快到了。 It should be : 它应该是 :

=IF((H11-J11)<0,abs(H11-J11) & " Days overdue",(abs(H11-TODAY())) & " Days Until Due")

In fact you are just missing the string concatenation character & . 实际上你只是缺少字符串连接字符&

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

相关问题 如何在多个文件中搜索字符串并在 Excel 或 Powershell 中的 csv 中返回带有行号/文本的文件名 - How to search a string in multiple files and return file name with line number/text in an Excel or csv in Powershell 如果ASCII字符串包含字母或数字,则返回文本 - If ASCII String Contains Letter or Number, Then Return Text excel:如果包含文本字符串,如何返回整个单元格 - excel : how to return the entire cell if it contains a text string 如何从 Excel 中的文本字符串中调用正确的数字? - How do I recall the correct number from a text string in Excel? 在 Excel 的字符串字段中提取数字和括号之间的文本 - Extracting text between Number and Parantheses in a String field in Excel excel公式在文件路径文本字符串中找到零件号 - excel formula find part number in file path text string 在文本文件中搜索多行字符串并返回 Python 中的行号 - Search a text file for a multi line string and return line number in Python 将数字转换为excel的字符串 - Converting a number to a string for excel 结合使用VBA和Excel 2007将字符串中存储的数字与包含以文本格式设置的数字的单元格进行比较 - Using VBA with excel 2007 to compare a number stored in a string to a cell which contains a number formatted as text 文本字符串中的Excel *符号 - Excel * symbol in a text string
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM