[英]Excel [VBA] Select Column within Table and insert data to empty cells
我有一张表格,有时 G 列(第 7 列)中会丢失数据。
到目前为止,我用鼠标在此列中选择了一个范围,然后运行此宏以使用“无数据”填充空单元格:
Sub FillEmptyCell()
Dim cell As Range
Dim InputValue As String
For Each cell In Selection
If IsEmpty(cell) Then
cell.Value = "No Data"
End If
Next
End Sub
然而,该列中的数据越来越多,我想自动选择第 7 列的整个表格范围,并用“无数据”填充空单元格。
我该如何实施?
尝试这个
Dim lr As Long
lr = Cells(Rows.Count, 7).End(xlUp).Row
Dim Rng As Range
Set Rng = Range("G1:G" & lr)
For Each cell In Rng
If IsEmpty(cell) Then
cell.Value = "No Data"
End If
Next
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.