0
0

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.

【VBA】セル移動でマクロ自動実行

Last updated at Posted at 2019-04-23
worksheet
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
	Dim f1 As New UserForm1
	
	If ActiveCell.Value = "1" Then
		If flag Then
			f1.Show vbModeless
		Else
			UserForm1.Show vbModeless
		End If
	ElseIf ActiveCell.Value = "0" Then
		UserForm2.Show vbModeless
	Else
		If UserForm1.Visible Then
			Unload UserForm1
		End If
		If UserForm2.Visible Then
			Unload UserForm2
		End If
	End If
End Sub

button
Public flag As Boolean

Sub ボタン1_Click()
	If flag Then
		flag = False
	Else
		flag = True
	End If
	Range("G6") = flag
End Sub

■参考サイト
https://excel-excel.com/tips/vba_80.html
https://www.forguncy.com/blog/20181217_clickevent

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?