LoginSignup
0
2

More than 5 years have passed since last update.

ズンドコキヨシ for Excel VBA

Last updated at Posted at 2018-07-13

今更にも程がある、とは思ったが、せっかくなので書き残しておこう。

[できるだけ手短に]

Sub zd()
    Dim z, d
    z = 1
    Cells.Clear
    Do
        d = Round(Rnd())
        Cells(Len(z), 1) = IIf(d, "dk", "zn")
        z = z & d
    Loop Until Right(z, 5) = 1
    Cells(Len(z), 1) = "k.y.s!"
End Sub

[別解]

記事を書いたあとで別の方法を思いついたので試してみた。
ついでに、せっかくExcelに出すのだからと、表示の仕方に小細工を。

cap2.gif

Sub zdk()
    Dim z, d, k As Range
    Cells.Clear
    For Each k In Cells.Resize(1)
        k.Activate
        wait 1
        d = Round(Rnd())
        k = IIf(d, "ズン", "ドコ")
        z = d * (z + 1) - (d - 1) * (z = 4)
        k.Resize(, 4).Font.Size = k.Font.Size + d * 2
        If z < 0 Then Exit For
        If z > 4 Or d = 0 Then Cells.ClearFormats
        Cells.Rows.AutoFit
    Next
    For z = 1 To 3
        wait 0.2
        With k.Offset(, z)
            .Value = Mid("キ・ヨ・シ!", 2 * z - 1, 2)
            .Activate
        End With
    Next
End Sub

Function wait(s)
    wait = Timer: Do: DoEvents: Loop Until Timer > wait + s
End Function
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2