我想将第 4 列中的第 2 行更改为 10 行,但它不起作用。
限制:d As Single
不得更改
Sub ua()
Dim d As Single
Dim i As Integer
d = Cells(i, 4)
For i = 2 To 10
d = 10
Next i
End Sub
最佳答案
循环遍历行和列是一种选择:
Sub TestMe()
Dim myRow As Long, myCol As Long
Dim d As Single: d = 10
For myRow = 2 To 10
For myCol = 4 To 10
Worksheets(1).Cells(myRow, myCol) = d
Next myCol
Next myRow
End Sub
另一种是使用评论中@Jeep 的单行解决方案 -
With Workheets(1)
.Range(.Cells(2, 4), .Cells(10, 10)) = 10
end with
关于excel - 无法更改单元格值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53044718/