回答編集履歴

1

追記

2020/05/19 12:32

投稿

sinzou
sinzou

スコア392

test CHANGED
@@ -57,3 +57,85 @@
57
57
  ```
58
58
 
59
59
  と必要か所に``` Worksheets("Sheet1").Range("A1").AutoFilter ```を
60
+
61
+
62
+
63
+ 追記
64
+
65
+ ```vb
66
+
67
+ Private Sub CommandButton1_Click()
68
+
69
+ Dim Control1 As Control, Control2 As Control, Control3 As Control
70
+
71
+ Dim Sh1 As Worksheet, Sh2 As Worksheet
72
+
73
+ Set Sh1 = Worksheets("Sheet1")
74
+
75
+ Set Sh2 = Worksheets("Sheet2")
76
+
77
+ For Each Control1 In Frame1.Controls
78
+
79
+ If Control1.Value = True Then
80
+
81
+ For Each Control2 In Frame2.Controls
82
+
83
+ If Control2.Value = True Then
84
+
85
+ For Each Control3 In Frame3.Controls
86
+
87
+ If Control3.Value = True Then
88
+
89
+ Dim keyWord As String
90
+
91
+ keyWord = Control1.Caption & "_" & Control2.Caption & "_" & Control3.Caption
92
+
93
+ 'Sh1のデータをオートフィルターする
94
+
95
+ With Sh1.Range("A1")
96
+
97
+ .AutoFilter field:=1, Criteria1:=keyWord
98
+
99
+ '.CurrentRegion.Offset(1, 0).Columns("A:D").Copy
100
+
101
+ .CurrentRegion.Offset(1, 0).Resize(.CurrentRegion.Rows.Count - 1, 4).Copy
102
+
103
+ End With
104
+
105
+ 'Sheet2の2列目の最後の行の下に貼付
106
+
107
+ With Sh2.Range("A1").CurrentRegion
108
+
109
+ .Cells(.Rows.Count + 1, 1).PasteSpecial
110
+
111
+ End With
112
+
113
+ Exit Sub
114
+
115
+ End If
116
+
117
+ Next
118
+
119
+ MsgBox "産地未選択"
120
+
121
+ Exit Sub
122
+
123
+ End If
124
+
125
+ Next
126
+
127
+ MsgBox "サイズ_産地_未選択"
128
+
129
+ Exit Sub
130
+
131
+ End If
132
+
133
+ Next
134
+
135
+ MsgBox "商品_サイズ_産地_未選択"
136
+
137
+ End Sub
138
+
139
+
140
+
141
+ ```