2

I need to select a column from sheet1 and the selected column matches destination cell's row. I've got this code

INDIRECT(ADDRESS(2;ROW();;;"Sheet1")):INDIRECT(ADDRESS(101;ROW();;;"Sheet1")))

but it selects blank values (empty cells) as zeros insted of empty cells!

I tried to fix it with something like

IF(
    (
        INDIRECT(ADDRESS(2;ROW();;;"Sheet1")):INDIRECT(ADDRESS(101;ROW();;;"Sheet1"))
    )=0;
    "";
    (INDIRECT(ADDRESS(2;ROW();;;"Sheet1")):INDIRECT(ADDRESS(101;ROW();;;"Sheet1"))))

which of course doesn't work because I'm trying to apply the condition to a range instead of a value.

Is there any way to select the range INDIRECT(ADDRESS(2;ROW();;;"Sheet1")):INDIRECT(ADDRESS(101;ROW();;;"Sheet1")) picking the blanks as blanks instead of zeros?

4

2 回答 2

2

这是你正在尝试的吗?我已将您的公式放入TRIM()公式中。

=TRIM(INDIRECT(ADDRESS(2;ROW();;;"Sheet1")):INDIRECT(ADDRESS(101;ROW();;;"Sheet1"))))

注意Trim()将返回一个字符串。因此,如果单元格为空白,那么您将得到一个空白,但如果单元格有一个数字,那么您将得到数字作为字符串

请参阅此示例

在此处输入图像描述

于 2013-10-07T16:43:32.420 回答
0

我看到您可能不再需要答案,但我注意到您最初的尝试会起作用 - 您可以将 IF 应用于一个范围,即

=IF(INDIRECT(ADDRESS(2;ROW();;;"Sheet1")):INDIRECT(ADDRESS(101;ROW();;;"Sheet1"))="";"";INDIRECT(ADDRESS(2;ROW();;;"Sheet1")):INDIRECT(ADDRESS(101;ROW();;;"Sheet1")))

....但可能不需要 INDIRECT/ADDRESS 组合,您可以使用此公式返回原始数组

=INDEX(Sheet1!$2:$101;0;ROW())

然后只需对其应用一个简单的 IF 函数,即

=IF(INDEX(Sheet1!$2:$101;0;ROW())="";"",INDEX(Sheet1!$2:$101;0;ROW()))

这两个都将保持数值数字

于 2013-10-07T19:14:13.117 回答