3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ExcelVBAでズンドコキヨシ

Last updated at Posted at 2018-08-19

煎じまくられたネタではありますが、投稿テストも兼ねてズンドコキヨシをしてみました。


Sub Zundoko()

Dim Kiyoshiarr(1) As String
Dim ZunDokostr As String
Dim Zuncnt As Integer
Dim i As Integer
Dim k As Integer

Kiyoshiarr(0) = "ズン"
Kiyoshiarr(1) = "ドコ"
i = 1

Do
    k = Int(2 * Rnd)
    ZunDokostr = ZunDokostr + Kiyoshiarr(k)
   
    If Kiyoshiarr(k) = "ズン" And Zuncnt < 4 Then
        Zuncnt = Zuncnt + 1
    ElseIf Kiyoshiarr(k) = "ドコ" And Zuncnt = 4 Then
        ThisWorkbook.Worksheets(1).Cells(i, 1).Value = ZunDokostr & "キ・ヨ・シ!"
        Exit Do '整ったので終わり!
    Else
        ThisWorkbook.Worksheets(1).Cells(i, 1).Value = ZunDokostr
        ZunDokostr = ""
        i = i + 1
        Zuncnt = 0
    End If
Loop

End Sub

VBAズンドコキヨシ記事、すでにたくさんあるんですけどいくつかみると1セル1ワードのものが多く、「やっぱりズンドコキヨシは1フレーズで収まらないと」と思って失敗/成功が確定するまでは書き出してないです。

image.png

作って見てから他の人のを見るともっと短いやり方とかあって、VBAでも奥が深いなあと思った次第。

3
1
1

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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?