从 Excel 中的公式返回空单元格 [英] Return empty cell from formula in Excel

查看:52
本文介绍了从 Excel 中的公式返回空单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从 Excel 公式返回一个空单元格,但似乎 Excel 处理空字符串或对空单元格的引用与真正的空单元格不同.所以基本上我需要像

I need to return an empty cell from an Excel formula, but it appears that Excel treats an empty string or a reference to an empty cell differently than a true empty cell. So essentially I need something like

=IF(some_condition,EMPTY(),some_value)

我尝试做诸如

=IF(some_condition,"",some_value)

=IF(some_condition,,some_value)

假设 B1 是一个空单元格

and assuming B1 is an empty cell

=IF(some_condition,B1,some_value)

但这些似乎都不是真正的空单元格,我猜是因为它们是公式的结果.当且仅当满足某些条件时,有没有办法填充单元格,否则保持单元格真正为空?

but none of these appear to be true empty cells, I'm guessing because they are the result of a formula. Is there any way to populate a cell if and only if some condition is met and otherwise keep the cell truly empty?

按照建议,我尝试返回 NA(),但出于我的目的,这也不起作用.有没有办法用 VB 做到这一点?

as recommended, I tried to return NA(), but for my purposes this did not work either. Is there a way to do this with VB?

我正在构建一个工作表,该工作表从其他工作表中提取数据,该工作表的格式已根据将数据导入数据库的应用程序的特定需求进行格式化.我无权更改此应用程序的实现,如果值为 "" 而不是实际为空,则它会失败.

I am building a worksheet that pulls in data from other worksheets that is formatted to the very specific demands of an application that imports the data into a database. I do not have access to change the implementation of this application, and it fails if the value is "" instead of actually empty.

推荐答案

那么,您将不得不使用 VBA.您将遍历范围内的单元格,测试条件,并在匹配时删除内容.

You're going to have to use VBA, then. You'll iterate over the cells in your range, test the condition, and delete the contents if they match.

类似于:

For Each cell in SomeRange
  If (cell.value = SomeTest) Then cell.ClearContents
Next

这篇关于从 Excel 中的公式返回空单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆