VBA – find空单元格,设置为“EMPTY”
代码从工作表中find值并将它们复制到一张纸上。 如果一列完全是空的,它将打印“没有项目”。
我需要这样做,一旦它完成复制项目,它find列“B” (StartSht,“B”)中的 任何空白单元格和从“C”最后占用的单元格的范围, 填充它string“EMPTY”
任何想法我会怎么做呢?
它确实(1),我需要它做(2)
(1)
(2)
Set dict = GetValues(hc3.Offset(1, 0)) If dict.count > 0 Then 'add the values to the master list, column 2 Set d = StartSht.Cells(Rows.count, hc1.Column).End(xlUp).Offset(1, 0) d.Resize(dict.count, 1).Value = Application.Transpose(dict.items) Else 'if no items are under the HOLDER header StartSht.Range(StartSht.Cells(i, 2), StartSht.Cells(GetLastRowInColumn(StartSht, "C"), 1)) = " NO ITEMS " End If
使用SpecialCells
function很容易find空白单元格。 这与使用GoTo(或者按F5 )和selectBlanks
。
StartSheet.Range("B:B").SpecialCells(xlCellTypeBlanks).Value = "EMPTY"
build立适当的范围之后,您可以对列C执行相同的操作。
StartSht.Range(StartSht.Cells(GetLastRowInColumn(StartSht, "B"), 2), StartSht.Cells(GetLastRowInColumn(StartSht, "C"), 1)).SpecialCells(xlCellTypeBlanks).Value = "EMPTY"