如果单元格满足特定条件然后恢复正常,如何多次重复单元格?

newt335

我在 Excel 工作表中有数据。具体来说,我在列D和 E(和其他一些)中有数据我要填写的栏目F,并 G用一个公式,使用从列中的数据D和 E规则是:

  • 通常,应该与.FnDn
  • 如果是“抑郁症”或“恶性通货膨胀”,那么, 并且 应该是“大萧条”(即“大萧条”将重复接下来的三个单元),以及, 并 应被忽略。注意:一些文本值有尾随空格,因此需要。DnF(n+1)F(n+2)F(n+3)D(n+1)D(n+2)D(n+3)
    TRIM()
  • G应该来自E遵循相同的规则。

第二个子弹隐藏了一个微妙的陷阱。考虑这些数据:

D F G
59 沮丧 废话59 沮丧 废话59
60 高于平均水平 废话60 沮丧 废话60
61 沮丧 blah61 沮丧 blah61
62 平均数 blah62 沮丧 blah62
63 平均数 blah63 平均数 blah63
64 高于平均水平 blah64 高于平均水平 blah64

F59是“抑郁症”,因为它与D59. 但是,既然D59是“抑郁症”, F60, F61 并且 F62也被设置为“抑郁症”,并且D60, D61 和 D62被忽略。具体来说,我们忽略了同样D61是“抑郁症”的事实,因此我们不会将F63 and 设置F64为“抑郁症”,而是让它们等于D63 and  D64

有些已张贴(错误地)设置的答案F63 ,并 F64为“抑郁症”。


编辑:

如果 D 列中是“恶性通货膨胀”、“恶性通货膨胀”或“萧条”、“恶性通货膨胀”,您将如何解决?

“恶性通货膨胀”、“恶性通货膨胀”工作表: Excel 工作表

What I would like it to look like: Excel 工作表

"Depression","Hyperinflation" Worksheet: Excel 工作表

What I would like it to look like: Excel 工作表

So in column D, if the cell is "Hyperinflation" or "Depression", and within the next three cells there is another "Hyperinflation" or "Depression", I would not want to repeat them in column F. So the "Hyperinflation" or "Inflation" within the next three cells in column D would be ignored.

Dropbox Link: https://www.dropbox.com/scl/fi/wxfzk0r320wm57r7jge5b/PART-B.xlsx?dl=0&rlkey=z407ft00oi9e0i4m9qlvmmirh

Scott

I believe that it is impossible to do what the question asks for with a closed-form, single-cell formula.  Consider the following hypothetical data, with the corresponding desired results (as I understand the requirements):

Row D F
72 ant ant
73 bat bat
74 cat cat
75 dog dog
76 Depression Depression
77 illustration Depression
78 jackpot Depression
79 Depression Depression
80 kangaroo kangaroo
81 leopard leopard
82 Depression Depression
83 melody Depression
84 nighthawk Depression
85 Depression Depression
86 orange orange
87 purple purple

There's no local difference between Rows 83 & 84 and Rows 86 & 87.  I believe it's impossible for a formula in Column F (or G) to distinguish between those cases without looking at the entire D column.

Luckily, it seems to be fairly easy with helper columns.  Pick two columns that you aren't using.  They can be H and I, Y and Z, AF and AG, or whatever you want.  I'll assume that you choose H and I.

Assuming that your data start in Row 15 (as your question shows) and that cells H14 and I14 are empty (which should be the case, since I've assumed that you aren't using the helper columns), enter

=IF(AND(H14>0,H14<4), H14+1, --OR(TRIM(SUBSTITUTE(D15, CHAR(160), " "))="Depression",TRIM(SUBSTITUTE(D15, CHAR(160), " "))="Hyperinflation"))

into cell H15, and enter

=IF(H15>1, "Depression", TRIM(SUBSTITUTE(D15, CHAR(160), " ")))

into cell F15.  Copy F into G and H into I, and drag/fill down.

The value in the helper column is "normally" 0.  When H(n-1) is 0, Hn is set to --OR(D15="Depression",D15="Hyperinflation") (the final part of the IF expression).  We use TRIM() because the data in your file have trailing spaces, which cause the string comparison to fail.  We use SUBSTITUTE(cell, CHAR(160), " ") because the data in your file have trailing non-breaking spaces, which TRIM() doesn't handle, so we have to convert those to regular spaces before calling TRIM().  This OR expression is TRUE if Dn is equal to one of the two trigger words, and FALSE otherwise.  The -- turns these into 1 and 0.  A value of 1 indicates that this is the first row of a repeat block; a 0 indicates that it is another normal row.

如果为正但小于 4,则表示第n-1行 是重复块的一部分(但不是最后一行),因此第n行 必须是重复块的一部分(但不是第一行)。因此我们添加 1(表达式的中间部分),以表示第 n行是重复块的第 2、第 3 或第 4 行。如果 是 4,我们回到基于 的 设置H(n-1)IFH(n-1)HnDn

column 的公式F表示如果第 n行是重复块的第 2、3 或 4 行,则设置为“凹陷”;否则,它被设置为等于 FnDn

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何复制多次重复的单元格?

来自分类Dev

如何复制多次重复的单元格?

来自分类Dev

显示熊猫数据框中满足特定条件的所有单元格

来自分类Dev

Microsoft Excel如何选择满足特定条件(即大于某个值)的所有单元格

来自分类Dev

Excel,如果满足条件,则对包含字母数字单元格的单元格进行计数

来自分类Dev

如果满足条件,则为单元格添加值

来自分类Dev

如果满足多个条件,则将重复的单元格值计数为一个

来自分类Dev

满足条件时选择单元格

来自分类Dev

如果使用 Excel VBA 不满足条件,则编辑特定列中单元格的值

来自分类Dev

如何在PHP多维数组中引用具有特定条件的单元格

来自分类Dev

如何根据匹配特定条件的数据框单元格索引和打印列名

来自分类Dev

删除相邻的单元格(如果重复)?

来自分类Dev

如果不同的单元格是特定值,如何只计算单元格?

来自分类Dev

Excel VBA-如果单元格值满足条件,则在工作表之间复制单元格

来自分类Dev

对于范围中的每个单元格,如果满足条件,则将单元格值添加到数组

来自分类Dev

如果与相邻单元格的总和结果满足条件,则对谷歌表格中单元格的总和值进行求和

来自分类Dev

如果单元格为空,则条件

来自分类Dev

Excel-如何根据具有列表条件的特定条件允许自定义输入单元格

来自分类Dev

如何避免UICollectionView重复单元格?

来自分类Dev

如何计算重复的单元格值?

来自分类Dev

当上面的单元格满足条件时,在单元格中插入文本

来自分类Dev

UICollectionView重复单元格

来自分类Dev

UICollectionView重复单元格

来自分类Dev

UICollectionView重复单元格

来自分类Dev

从两个矩阵和特定条件中提取一个单元格

来自分类Dev

在具有特定条件的结构中选择单元格

来自分类Dev

从两个矩阵和特定条件中提取一个单元格

来自分类Dev

EXCEL:在特定条件下更改单元格的颜色

来自分类Dev

添加新行并在特定条件下复制单元格的值

Related 相关文章

  1. 1

    如何复制多次重复的单元格?

  2. 2

    如何复制多次重复的单元格?

  3. 3

    显示熊猫数据框中满足特定条件的所有单元格

  4. 4

    Microsoft Excel如何选择满足特定条件(即大于某个值)的所有单元格

  5. 5

    Excel,如果满足条件,则对包含字母数字单元格的单元格进行计数

  6. 6

    如果满足条件,则为单元格添加值

  7. 7

    如果满足多个条件,则将重复的单元格值计数为一个

  8. 8

    满足条件时选择单元格

  9. 9

    如果使用 Excel VBA 不满足条件,则编辑特定列中单元格的值

  10. 10

    如何在PHP多维数组中引用具有特定条件的单元格

  11. 11

    如何根据匹配特定条件的数据框单元格索引和打印列名

  12. 12

    删除相邻的单元格(如果重复)?

  13. 13

    如果不同的单元格是特定值,如何只计算单元格?

  14. 14

    Excel VBA-如果单元格值满足条件,则在工作表之间复制单元格

  15. 15

    对于范围中的每个单元格,如果满足条件,则将单元格值添加到数组

  16. 16

    如果与相邻单元格的总和结果满足条件,则对谷歌表格中单元格的总和值进行求和

  17. 17

    如果单元格为空,则条件

  18. 18

    Excel-如何根据具有列表条件的特定条件允许自定义输入单元格

  19. 19

    如何避免UICollectionView重复单元格?

  20. 20

    如何计算重复的单元格值?

  21. 21

    当上面的单元格满足条件时,在单元格中插入文本

  22. 22

    UICollectionView重复单元格

  23. 23

    UICollectionView重复单元格

  24. 24

    UICollectionView重复单元格

  25. 25

    从两个矩阵和特定条件中提取一个单元格

  26. 26

    在具有特定条件的结构中选择单元格

  27. 27

    从两个矩阵和特定条件中提取一个单元格

  28. 28

    EXCEL:在特定条件下更改单元格的颜色

  29. 29

    添加新行并在特定条件下复制单元格的值

热门标签

归档