1 + 3 * 1 = 4
4 + 3 * 2 = 10
10 + 3 * 3 = 19
我想在单元格A4,A10,A19中输入“A”。我想为25个细胞做到这一点。
如何做到
答案 0 :(得分:0)
你必须测试你是否不会走得太远:
Sub test_matangraj()
Dim i As Integer
Dim k As Integer
Dim Col As Long
Col = 1
For i = 1 To 25
Col = Col + i * 3
If Col < Columns.Count Then
Cells(1, Col) = "A"
For k = 1 To i - 1
If Col + k < Columns.Count Then Cells(1, Col + k) = "A"
Next k
Else
MsgBox "Number of columns excedeed!" & vbcrlfr & _
"Col: " & Col, vbCritical + vbOKOnly
Exit For
End If
Next i
End Sub