使用空白下方的下一个值填充空白单元格

时间:2015-04-16 22:31:53

标签: excel excel-vba excel-formula vba

我已经看到很多帖子从上面的单元格填充空白单元格。但这是相反的事情。在这里,我们可以从下面的单元格填充空白单元格。

当前

A1 = blank
A2 = blank
A3 = blank
A4 = data

希望:

A1 = data from A4
A2 = data from A4
A3 = data from A4
A4 = data

4 个答案:

答案 0 :(得分:0)

<强>解决方案:

1. Select A1:A3
2. Press Enter till the active cell become A3 (just before/above the required value)
3. Enter "=" (without quotes)
4. Press the Down cursor key once/Select the below cell value
5. Press Ctrl+Enter

同样对于完整专栏,我们可以通过传统的Excel技术和选项:

1. Select the Column where you need to fill the blanks
2. Home -> Find & Select -> Select Blank Function(it will select all the blanks in your selection)
3. Now hit enter until reach a cell which is just before the required cell value.
4. Press "="
5. Press the Down key once / Select the below cell value
6. Hit: Ctrl + Enter

答案 1 :(得分:0)

如果您事先知道 A4 是要向上复制的单元格,那么:

Sub FillCells()
    Range("A1:A3").Value = Range("A4").Value
End Sub

如果您不知道填充了哪个单元格,那么:

Sub FillCells2()
    Dim N As Long
    N = Cells(Rows.Count, 1).End(xlUp).Row
    Range("A1:A" & N - 1).Value = Range("A" & N).Value
End Sub

答案 2 :(得分:0)

  1. 选择A1
  2. 按&#34; F2&#34;
  3. 输入&#34; = $ A $ 4&#34; (没有引号)或&#34; = R4C1&#34; (如果是R1C1风格)
  4. 按&#34;输入&#34;
  5. 按Ctrl + C
  6. 选择A2和A3单元格
  7. 按Ctrl + V

答案 3 :(得分:0)

填写 - 并处理单独的空白区域:

Sub FillUp()
Dim rng1 As Range
On Error Resume Next
Set rng1 = Range([a1], Cells(Rows.Count, "A").End(xlUp)).SpecialCells(xlBlanks)
On Error GoTo 0
If rng1 Is Nothing Then Exit Sub
rng1.FormulaR1C1 = "=R[1]C"
rng1.Value = rng1.Value
End Sub