1Private Sub CommandButton1_Click()
2 Dim Control1 As Control
3 Dim Control2 As Control
4 Dim Control3 As Control
56 For Each Control1 In Frame1.Controls
7 If Control1.Value = True Then Exit For
8 Next
9 For Each Control2 In Frame2.Controls
10 If Control2.Value = True Then Exit For
11 Next
12 For Each Control3 In Frame3.Controls
13 If Control3.Value = True Then
14 MsgBox Control1.Caption & "_" & Control2.Caption & "_" & Control3.Caption
15 Exit For
16 End If
17 Next
18End Sub
追記、
VBA
1Private Sub OptionButton1_AfterUpdate()
2 Call Chk1
3End Sub
45Private Sub OptionButton2_AfterUpdate()
6 Call Chk1
7End Sub
89Private Sub OptionButton3_AfterUpdate()
10 Call Chk1
11End Sub
1213Private Sub OptionButton4_AfterUpdate()
14 Call Chk1
15End Sub
16Sub Chk1()
17 Dim Control1 As Control
18 Dim Control2 As Control
19 Dim Chk As Boolean
20 Dim myRange As Range
21 Dim myObj As Range
22 Dim keyWord As String
23 Set myRange = Range("A:A")
2425 For Each Control1 In Frame1.Controls
26 If Control1.Value = True Then
27 Chk = True
28 Exit For
29 End If
30 Next
31 If Chk = True Then
32 For Each Control2 In Frame2.Controls
33 keyWord = Control1.Caption & "_" & Control2.Caption & "_*"
34 Set myObj = myRange.Find(keyWord, LookAt:=xlWhole)
35 If myObj Is Nothing Then
36 Control2.Enabled = False
37 Control2.Value = False
38 Else
39 Control2.Enabled = True
40 Control2.Value = False
41 End If
42 Next
43 For Each Control3 In Frame3.Controls
44 Control3.Enabled = False
45 Control3.Value = False
46 Next
47 End If
48End Sub
4950Private Sub OptionButton5_AfterUpdate()
51 Call Chk2
52End Sub
5354Private Sub OptionButton6_AfterUpdate()
55 Call Chk2
56End Sub
57Private Sub OptionButton7_AfterUpdate()
58 Call Chk2
59End Sub
60Sub Chk2()
61 Dim Control1 As Control
62 Dim Control2 As Control
63 Dim Control3 As Control
64 Dim Chk As Boolean
65 Dim myRange As Range
66 Dim myObj As Range
67 Dim keyWord As String
68 Set myRange = Range("A:A")
6970 For Each Control1 In Frame1.Controls
71 If Control1.Value = True Then Exit For
72 Next
73 For Each Control2 In Frame2.Controls
74 If Control2.Value = True Then
75 Chk = True
76 Exit For
77 End If
78 Next
79 If Chk = True Then
80 For Each Control3 In Frame3.Controls
81 keyWord = Control1.Caption & "_" & Control2.Caption & "_" & Control3.Caption
82 Debug.Print keyWord
83 Set myObj = myRange.Find(keyWord, LookAt:=xlWhole)
84 If myObj Is Nothing Then
85 Control3.Enabled = False
86 Control3.Value = False
87 Else
88 Control3.Enabled = True
89 Control3.Value = False
90 End If
91 Next
92 End If
93End Sub
1Sub test01()
23Dim MyCtrl As Object
4Dim InCtrl As Object
5Dim MyStr As String
6 With UserForm1
7 For Each MyCtrl In .Controls
8 If InStr(MyCtrl.Name, "Frame") > 0 Then
9 For Each InCtrl In MyCtrl.Controls
10 MyStr = MyStr & MyCtrl.Name & "-" & InCtrl.Name & vbCrLf
11 Next
12 End If
13 MyStr = MyStr & MyCtrl.Name & vbCrLf
14 Next
15 MsgBox MyStr
16 End With
17End Sub
18
1Private Sub ComboBox2_Change()
23Dim MyData3 As New Collection
4Dim cnt3 As Long
5Dim i3 As Long
678cnt3 = Sheets("master").Range("A1").CurrentRegion.Rows.Count
910商品名 = ComboBox1.Text
11サイズ = ComboBox2.Text
1213ComboBox3.Clear
1415 On Error Resume Next
16 For i3 = 2 To cnt3
1718 If Sheets("master").Range("B" & i3).Value = 商品名 Then
1920 If Sheets("master").Range("C" & i3).Value = サイズ Then
21 MyData3.Add Sheets("master").Range("D" & i3).Value, Sheets("master").Range("D" & i3).Value
22 End If
23 End If
2425 Next i3
26 On Error GoTo 0
2728 For i3 = 1 To MyData3.Count
2930 ComboBox3.AddItem MyData3(i3)
31 Next
323334End Sub
35Private Sub ComboBox1_Change()
36Dim MyData2 As New Collection
37Dim cnt2 As Long
38Dim i2 As Long
394041cnt2 = Sheets("master").Range("A1").CurrentRegion.Rows.Count
4243商品名 = ComboBox1.Text
4445ComboBox2.Clear
4647 '■重複しない商品名のリストを作成(エラーを無視)
48 On Error Resume Next
49 For i2 = 2 To cnt2
5051 If Sheets("master").Range("B" & i2).Value = 商品名 Then
5253 MyData2.Add Sheets("master").Range("C" & i2).Value, Sheets("master").Range("C" & i2).Value
54 End If
5556 Next i2
57 On Error GoTo 0
5859 '■商品名のリストを作成
6061 For i2 = 1 To MyData2.Count
6263 ComboBox2.AddItem MyData2(i2)
64 Next
656667End Sub
6869Private Sub UserForm_Initialize()
70Dim MyData1 As New Collection
7172Dim cnt As Long
73Dim i As Long
7475 cnt = Sheets("master").Range("A1").CurrentRegion.Rows.Count
7677 '■重複しない商品名のリストを作成(エラーを無視)
78 On Error Resume Next
79 For i = 2 To cnt
8081 MyData1.Add Sheets("master").Range("B" & i).Value, Sheets("master").Range("B" & i).Value
8283 Next i
84 On Error GoTo 0
8586 '■商品名のリストを作成
8788 For i = 1 To MyData1.Count
8990 ComboBox1.AddItem MyData1(i)
91 Next
9293End Sub
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/05/04 13:33
2020/05/05 03:30
2020/05/05 04:41
2020/05/05 11:34
2020/05/05 14:08
2020/05/05 14:32