[英]Change VBA code with an Excel formula
I have a column in excel with a formula =IF(O10="";"";IF(O9=O10;"";N9-3))
. 我在excel中有一列公式
=IF(O10="";"";IF(O9=O10;"";N9-3))
。 This formula does not produce a result every time. 此公式不会每次都产生结果。 Sometimes the cells are empty.
有时单元格是空的。 So I want to copy only the filled cells in another column in order to have them sorted next to eachother.
因此,我只想将填充的单元格复制到另一列中,以使它们彼此相邻排序。 For example
例如
N O P R
1 5 1
2 6 4
3 7
4 7 1
5 8
6 9
7 9 4
I did it with the following macro 我用下面的宏做到了
Sub Roll2()
Range("R7:R2500").ClearContents
With Range("P7:P2500")
.Offset(, 0).SpecialCells(xlCellTypeFormulas, xlNumbers).Copy
'^--| consider cells with number value resulting from the formula
.Offset(, 2).PasteSpecial SkipBlanks:=True, Paste:=xlPasteValues
End With
End Sub
Can I somehow do it without the macro? 没有宏,我能以某种方式做到这一点吗? I have a large workbook, which is built only with excel and I would like to avoid having 5 lines of code if I can.
我有一本很大的工作簿,仅使用excel构建,如果可以的话,我希望避免使用5行代码。
我这样解决了
{=IFERROR(INDEX($P$7:$P$1353;SMALL(IF(LEN($P$7:$P$1353)>2;ROW($P$7:$P$1353)-ROW($P$6));ROW(14:14));1);"")}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.