我想写将宏:遍历范围内的每一行,并填写空格,如果> 1空白
'loop through each row in a 4 column range
'count the blanks
'if there is more than 1 blank anywhere in the row, fill all blanks with "100"
'if there is 1 or less blanks, leave everything blank
我已经搜查这些板一吨找到VBA代码,将循环通过行,并根据我在这里找到的东西创建了一个复合宏,除了填充每行内的空白外,它工作正常,它填补了列B和C中的空白(它出现在我指定的范围之前)。因为B和C都是完全空白的,所以我只能得到一个100的墙。
下面的代码:
`Sub fillCellsUp()
Dim row As Range
Dim rng As Range
Dim BCount As Long
Dim nextrow As Long
Dim hundred As Integer
hundred = 100
nextrow = ActiveSheet.UsedRange.Rows.Count
Set rng = Worksheets("Worksheet1").Range("D2:G534")
Set row = Range(Cells(nextrow, 4), Cells(nextrow, 7))
For Each row In rng
On Error Resume Next
BCount = row.Cells.SpecialCells(xlCellTypeBlanks).Count
If BCount > 1 Then row.Cells.SpecialCells(xlCellTypeBlanks).Value = hundred
nextrow = nextrow - 1
Next row
End Sub`
我已经包括了实际的Excel文件,我试图填补的图像:
抱歉 - 图像没有上传正确:http://tinypic.com/r/k573b/9 –