Excel VBA-从相邻单元格检查数组 [英] Excel VBA - Checking array from adjacent cell

查看:57
本文介绍了Excel VBA-从相邻单元格检查数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在D13:D19中有一个数组设置,用户可以在其中输入值.我正在修改工作表中的公式,使其不依赖于所输入的所有单元格.

I have an array setup in D13:D19 where values are entered by the user. I'm modifying the formulas in my sheet to not be dependant on all cells being input.

在与数组相邻的列中,它显示了从上一个单元格开始的更改,如下所示:

In the column adjacent to the array I have it showing the change from the previous cell like so:

=IF([@[Weight (lbs)]]="","",[@[Weight (lbs)]]-D17) 

其中 D17 是当前行[第18行]上方的单元格.

Where D17 is the cell above the current row [row 18].

我需要重做一次,以便它在相邻的单元格中查找整数,如果存在整数,则它将检查其上方的数组中的最后一个值,并在公式中使用该值.如果不存在整数,则该单元格保持空白.

I need to redo this so that it looks at the adjacent cell for an integer, if an integer exists then it checks the array above it for the last value and uses that value in the formula. If no integer exists the cell remains blank.

示例:

Cell D15 = 155 
Cell D16 = 155 
Cell D17 = BLANK 
Cell D18 = 145

在E18中,该公式将需要查看D18以查看是否存在整数,如果是,则它将查找数组中最后一个填充的单元格(在本示例中为D16).然后它将从D18 [D18-D16]中减去最后输入的单元格.

In E18, the formula will need to look at D18 to see if there is an integer, if yes then it will then look for the last filled cell in the array which in this example is D16. Then it will subtract the last entered cell from D18 [D18-D16].

推荐答案

将其替换为公式中的 D17 :

INDEX(D:D,MATCH(1E+99,D1:INDEX(D:D,ROW()-1)))

它将返回最后一个单元格的值,该单元格的当前行上方是一个数字.

It will return the value of the last cell with a number above the current row.

这篇关于Excel VBA-从相邻单元格检查数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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