I have a column in excel with a formula =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.
我这样解决了
{=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);"")}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.