ブック本体の非表示
Option Explicit
Private Sub CommandButton1_Click()
'Window本体の表示・非表示
'メモ
'---------------------------------
'全BookのWindow
'Application.Visible = True
'---------------------------------
'ThisWorkbookのWindowのみ
'Windows(ThisWorkbook.Name).Visible = True
'---------------------------------
If Windows(ThisWorkbook.Name).Visible = True Then
Windows(ThisWorkbook.Name).Visible = False
Else
Windows(ThisWorkbook.Name).Visible = True
End If
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
'[X]ボタン押下時にWindow本体を表示にする
Windows(ThisWorkbook.Name).Visible = True
End Sub
コンボボックス / リストボックス
イニシャライズ
Private Sub UserForm_Initialize()
'UserFormが表示される際に実行
'処理
End Sub
アイテム追加
'コンボボックス
'①単体追加
UserForm1.ComboBox1.AddItem "aaa"
'②配列追加
Dim cmbList()
cmbList = Array("bbb", "ccc")
UserForm1.ComboBox1.List = cmbList
'③Range範囲追加
UserForm1.ComboBox1.RowSource = Worksheets("Sheet1").Range("A1:A3").Address(External:=True)
'リストボックス
With UserForm1.ListBox1
.ColumnCount = 2
.ColumnWidths = "20;80"
.List = Worksheets("Sheet1").Range("A1:B3").value
End With
アイテム取得
'値の取り方
Dim cmbValue As String, listValue As String
cmbValue = UserForm1.ComboBox1.Text
listValue = UserForm1.ListBox1.Text
MsgBox (cmbValue & vbTab & listValue)