【发布时间】:2018-06-21 12:53:01
【问题描述】:
【问题讨论】:
【问题讨论】:
假设单元格 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
数据:
宏之后的输出(如预期):
【讨论】:
你可以参考这个答案。与您的需求完全相关。
https://superuser.com/questions/603318/in-excel-how-do-you-auto-fill-until-next-value/603329.
为了您的方便,下面列出了步骤。
假设单元格 A1 始终以国家/地区开头
【讨论】: