【问题标题】:Auto-filling In ExcelExcel中的自动填写
【发布时间】:2018-06-21 12:53:01
【问题描述】:

我有一个如下所示的数据集:

我想在 A 列的空白单元格中填写相应国家/地区的名称。

我可以在 Excel 中自动完成吗?

【问题讨论】:

    标签: excel autofill


    【解决方案1】:

    假设单元格 A1 始终以国家开头,并且 B 列中的数据始终完整(最后一个单元格始终具有值)

    Private Sub fill_countries()
        Dim tmp as Variant
        Dim lr as Long
        lr = Cells(Rows.Count, "B").End(xlUp).Row
    
        For each cell in Columns(1).Cells
           If Not IsEmpty(cell) Then
               tmp = cell.Value
           End If
           cell.Value = tmp
    
           If cell.Row = lr Then 'safety measure so we don't end up with endless loops _
                                  after going through last data item
              Exit For
           End If
    
        Next cell
    End Sub
    

    数据:

    宏之后的输出(如预期):

    【讨论】:

      【解决方案2】:

      你可以参考这个答案。与您的需求完全相关。

      https://superuser.com/questions/603318/in-excel-how-do-you-auto-fill-until-next-value/603329.

      为了您的方便,下面列出了步骤。

      假设单元格 A1 始终以国家/地区开头

      1. Ctrl + A(全选)
      2. 按 F5
      3. 选择特殊
      4. 选择空白
      5. 按 =,然后按向上箭头,然后按 enterKey

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-06-13
        • 2010-11-28
        • 2015-09-09
        • 1970-01-01
        相关资源
        最近更新 更多