我的代碼在空白單元格中放置了文本,但沒有填充到邊界線上。在空白單元格中放置文本「general」
我想將文本「一般」放在E列的空白單元格中,但不會填充到rowcount的最後bcoz。
這裏是我的代碼:
Sub FindandReplace()
Dim sourceCol As Integer, rowCount As Integer, currentRow As Integer
Dim currentRowValue As String
sourceCol = 5 'column E has a value of 5
rowCount = Cells(Rows.Count, sourceCol).End(xlUp).Row
'for every row, find the first blank cell and select it
For currentRow = 1 To rowCount
currentRowValue = Cells(currentRow, sourceCol).Value
If IsEmpty(currentRowValue) Or currentRowValue = "" Then
Cells(currentRow, sourceCol) = "general"
End If
Next
End Sub
結果是這樣的:(仍然是空列E)
Column E Column F
general Use-Limit
general Use-Limit
XL354L,XL354H,XL356L,XL356H Use-Limit
XL353,XL355,XL357 Use-Limit
Use-Limit
Use-Limit
Use-Limit
Use-Limit
你有'sourceCol = 5''列的F值爲5,實際上列F的值爲6,所以如果你想使用F列,修改爲'sourceCol = 6' –
SOrry,據說是列E –
看着我回答如下。 –