-1

こんにちは皆さん、私はここではちょっと新しいので、ポイントに直行します

Excel でループを使用してジグザグ出力を作成する方法

例:

2  4  6  8 10

20 18 16 14 12

22 24 26 28 30

40 38 36 34 32

42 44 46 48 50

ここのコードで何が問題なのかわかりません

Sub lol()

a = 0
b = 2

For x = 1 To 20
    For y = 1 To 5

       If x = 5 Then
          For Z = 5 To 1 Step -1

              Cells(x, Z) = a
              a = a + b

          Next

          GoTo nextloop

       End If

       Cells(x, y) = a
       a = a + b

       nextloop:

    Next
Next

End Sub

前もって感謝します!

4

1 に答える 1

1

これを試して

Sub lol()
    Dim a As Long, b As Long
    Dim frm As Long, too As Long, stp As Long
    Dim x As Long, y As Long
    a = 2
    b = 2
    For x = 1 To 20
        If x Mod 2 > 0 Then
            frm = 1
            too = 5
            stp = 1
        Else
            frm = 5
            too = 1
            stp = -1
        End If
        For y = frm To too Step stp
            Cells(x, y) = a
            a = a + b
        Next
    Next
End Sub
于 2013-07-17T07:47:28.847 に答える