2 回答
A couple of suggestions:
- Using this array formula from Pearson - screenshot below
- A manual (non-VBA) SpecialCells method which is easier
SpecialCells method
- copy the column with gaps to the right
- select the new column, Press F5,
Special
and check blanks - right click, select
Delete
and then checlkshift cells up
The first two steps of this 3 step process (selecting the blanks) are shown here at Debra Dalgleish's site
Array Formula method
Give this a shot, entered as an array formula with Ctrl+Shift+Enter
):
Quickly paste-able version (note: you will need to change these references to those in your sheet - I used data in A1:A7
in mine [see image]):
=IFERROR(INDEX($A$1:$A$7, SMALL(--(IF($A$1:$A$7<>"",ROW($A$1:$A$7),100000)),ROW())), "")
Longer-form (to better see what is going on):
=IFERROR(
INDEX(
$A$1:$A$7,
SMALL(
--(IF($A$1:$A$7<>"",ROW($A$1:$A$7),100000)),ROW())),
"")
Basically, we use an index formula on the column. The row
argument uses the SMALL()
formula to find all instances where the column contains empty values, and then assigns an arbitrarily high number that hopefully won't ever be matched (this may be bad practice :) ). The k
argument to SMALL()
(the kth element in the array you want to match) is just the row number, meaning that as you go down the list, you won't match items above the current one.