ThisWorkbook ソース選択 Option Explicit Private Sub Workbook_Open() Dim menu1 As CommandBar Dim menu2 As CommandBarControl Set menu1 = Application.CommandBars("worksheet menu bar") Set menu2 = menu1.Controls.Add(Type:=msoControlPopup, Temporary:=True) menu2.Caption = "MM法" With menu2 .Controls.Add Type:=msoControlButton With .Controls(1) .Caption = "買売一括抽出" .OnAction = "買売一括抽出" .FaceId = 532 End With .Controls.Add Type:=msoControlButton With .Controls(2) .Caption = " 買銘柄抽出" .OnAction = "買銘柄抽出" End With .Controls.Add Type:=msoControlButton With .Controls(3) .Caption = " 売銘柄抽出" .OnAction = "売銘柄抽出" End With .Controls.Add Type:=msoControlButton With .Controls(4) .BeginGroup = True '区切り縦線 .Caption = "指定銘柄解析" .OnAction = "指定銘柄解析" .FaceId = 302 End With .Controls.Add Type:=msoControlButton With .Controls(5) .BeginGroup = True '区切り縦線 .Caption = "銘柄リスト解析" .OnAction = "銘柄リスト解析" .FaceId = 989 End With .Controls.Add Type:=msoControlButton With .Controls(6) .Caption = " 銘柄リスト保存" .OnAction = "銘柄リスト保存" End With .Controls.Add Type:=msoControlButton With .Controls(7) .BeginGroup = True '区切り縦線 .Caption = "抽出条件変更" .OnAction = "抽出条件変更" .FaceId = 526 End With .Controls.Add Type:=msoControlButton With .Controls(8) .BeginGroup = True '区切り縦線 .Caption = "投資の杜Webページ" .OnAction = "投資の杜Webページ" .FaceId = 1576 End With End With '抽出判定既定値設定 RSI買 = 25 'RSI買判定値 RSI売 = 75 'RSI売判定値 ADX買売 = 75 'ADX判定値 End Sub ThisWorkbook
UserForm1 ソース選択 Option Explicit Private Sub CommandButton1_Click() Application.CutCopyMode = False 'コピーモードを解除する Call 銘柄指定 Call 指標選択 Unload Me 'ユーザーフォームを消す End Sub Private Sub 銘柄指定() 銘柄コード = Me.TextBox1.Text If 銘柄コード = "" Or Len(銘柄コード) <> 4 Then MsgBox "取得する銘柄コード(数字4桁)を入力して下さい" Exit Sub End If End Sub Private Sub 指標選択() If Me.OptionButton1.Value = True Then 指標 = "ボリンジャー" ElseIf Me.OptionButton2.Value = True Then 指標 = "RSI" ElseIf Me.OptionButton3.Value = True Then 指標 = "ADX" ElseIf Me.OptionButton4.Value = True Then 指標 = "MACD" ElseIf Me.OptionButton5.Value = True Then 指標 = "RRR" ElseIf Me.OptionButton6.Value = True Then 指標 = "出来比" ElseIf Me.OptionButton7.Value = True Then 指標 = "終値比" ElseIf Me.OptionButton8.Value = True Then 指標 = "乖離率" ElseIf Me.OptionButton9.Value = True Then 指標 = "全指標" Else 指標 = "" End If End Sub Private Sub CommandButton2_Click() 銘柄コード = "" 指標 = "" Unload Me 'ユーザーフォームを消す End Sub Private Sub UserForm_Initialize() Me.OptionButton9.Value = True Me.TextBox1.SetFocus 'テキストボックスにフォーカスを合わす End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode <> vbFormCode Then 'マクロから閉じられたのではないなら Cancel = True '閉じる[×]ボタンを無効にする End If End Sub
UserForm2 ソース選択 Option Explicit Private Sub CommandButton1_Click() Application.CutCopyMode = False 'コピーモードを解除する RSI買 = Me.TextBox1.Text RSI売 = Me.TextBox2.Text ADX買売 = Me.TextBox3.Text Unload Me 'ユーザーフォームを消す End Sub Private Sub CommandButton2_Click() Unload Me 'ユーザーフォームを消す End Sub Private Sub UserForm_Initialize() Me.TextBox1.Text = RSI買 Me.TextBox2.Text = RSI売 Me.TextBox3.Text = ADX買売 End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode <> vbFormCode Then 'マクロから閉じられたのではないなら Cancel = True '閉じる[×]ボタンを無効にする End If End Sub UserForm1 UserForm2