解決済みの質問
ストップボタンはないけれど、こんなの作ってみました。
まっさらなワークシートで試してみてください。
Sub ルーレット()
Range("B3:K9").Select
With Selection
.Font.Name = "Arial Black"
.Font.Size = 20
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
With .Borders
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
End With
ActiveWorkbook.Names.Add Name:="table", RefersTo:=Selection
n = 0
For Each c In Range("table")
n = n + 1
c.Value = n
Next
For i = 1 To 2
For Each c In Range("table")
c.Select
For m = 20 To 3 Step -1
Selection.Interior.ColorIndex = m
Next m
Range("table").Interior.ColorIndex = 0
Next c
Next i
Randomize
x = Int(Rnd * 70) + 1
For Each c In Range("table")
c.Select
For m = 20 To 3 Step -1
Selection.Interior.ColorIndex = m
Next m
Range("table").Interior.ColorIndex = 0
If c.Value = x Then
Selection.Interior.ColorIndex = 3
Exit Sub
End If
Next c
End Sub
投稿日時 - 2005-07-22 15:38:02
1人が「このQ&Aが役に立った」と投票しています
ベストアンサー以外の回答(6件中 1~5件目)
ワークシートSheet1にオートシェイプの中から太い矢印を貼り付けました。
「オートシェイプ 2」という名前でした。
もうひとつ、コマンドボタンを貼り付けました。
Sheet1のコマンドボタンのクリックイベントに
Private Sub CommandButton1_Click()
Worksheets("sheet1").Range("a1").Activate
For i = 2 To 10
t0 = Timer
Do While Timer < t0 + 1
DoEvents
'ActiveSheet.Cells(i - 1, "A") = ""
'Cells(i, "A") = "A"
Worksheets("sheet1").Shapes("オートシェイプ 2").Left = i * 50
Loop
Next i
End Sub
を貼り付けます。
ボタンをクリックするとかくかくと10秒間、矢印が動いていきます。
スムーズにするには1秒をもっと短くする。
太い矢印を、イメージのピクチャなどに変える。
とめるのはとめるフラグを聞いていて、ONならシェイプをDeleteする。コンなのはどうでしょう。やはり道具立ての力不足ですね。
オフィス系などでなく・エクセルVBA以外のプログラム言語に目を向けられることを。
投稿日時 - 2005-07-22 23:31:46
No5です。こっちのほうがいいかも
Sub ルーレット開始()
Cells(1, 1) = ""
Range("B3:K9").Select
With Selection
.Font.Name = "Arial Black"
.Font.Size = 20
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
With .Borders
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
End With
ActiveWorkbook.Names.Add Name:="table", RefersTo:=Selection
Range("table").Interior.ColorIndex = 0
n = 0
For Each c In Range("table")
n = n + 1
c.Value = n
Next
Do
For Each c In Range("table")
c.Select
If Cells(1, 1) = "stop" Then
Selection.Interior.ColorIndex = 3
Exit Sub
End If
DoEvents
Next c
Loop
End Sub
Sub ルーレットSTOP()
Cells(1, 1) = "stop"
End Sub
投稿日時 - 2005-07-22 22:53:38
No4さんのをそのまま拝借してストップボタンを付けてみました。
Sub ルーレットSTART()
Cells(1, 1) = ""
Range("B3:K9").Select
With Selection
.Font.Name = "Arial Black"
.Font.Size = 20
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
With .Borders
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
End With
ActiveWorkbook.Names.Add Name:="table", RefersTo:=Selection
n = 0
For Each c In Range("table")
n = n + 1
c.Value = n
Next
Do While Cells(1, 1) = ""
For Each c In Range("table")
c.Select
If Cells(1, 1) = "stop" Then
Selection.Interior.ColorIndex = 3
Exit Sub
End If
DoEvents
Range("table").Interior.ColorIndex = 0
Next c
Loop
End Sub
Sub ルーレットSTOP()
Cells(1, 1) = "stop"
End Sub
投稿日時 - 2005-07-22 22:46:24
OKWaveのオススメ
おすすめリンク