軟體: EXCEL
版本: 2016
大家好 看書自學excel vba有個基本概念不懂
例如1到100能被3整除的數字依序寫入A欄
Sub mod3()
Dim i As Integer
xrow = 1
For i = 1 To 100
If i Mod 3 = 0 Then
Cells(xrow, "A").Value = i
xrow = xrow + 1
End If
Next
End Sub
那我把xrow = xrow + 1和 End If 對調 會造成每三列才會出現數字
原因為何?謝謝!
Sub mod3()
Dim i As Integer
xrow = 1
For i = 1 To 100
If i Mod 3 = 0 Then
Cells(xrow, "A").Value = i
End If
xrow = xrow + 1
Next
End Sub