teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

修正

2020/05/19 02:13

投稿

koko2
koko2

スコア21

title CHANGED
File without changes
body CHANGED
@@ -35,6 +35,7 @@
35
35
  Dim Control2 As Control
36
36
  Dim Control3 As Control
37
37
  Dim keyWord As String
38
+  keyWord = Control1.Caption & "_" & Control2.Caption & "_" & Control3.Caption
38
39
 
39
40
  For Each Control1 In Frame1.Controls
40
41
  If Control1.Value = True Then Exit For

2

誤記

2020/05/19 02:13

投稿

koko2
koko2

スコア21

title CHANGED
File without changes
body CHANGED
@@ -29,7 +29,8 @@
29
29
  2.コマンドボタン2を押したら、ユーザーフォームのボタンの値を一度にクリア(初期状態)にする方法を教えてください。
30
30
 
31
31
  <修正しました>
32
+ ```
32
- ```Private Sub CommandButton1_Click()
33
+ Private Sub CommandButton1_Click()
33
34
  Dim Control1 As Control
34
35
  Dim Control2 As Control
35
36
  Dim Control3 As Control

1

追記しました。

2020/05/19 02:01

投稿

koko2
koko2

スコア21

title CHANGED
File without changes
body CHANGED
@@ -26,4 +26,38 @@
26
26
  <エラー箇所>
27
27
  1.コマンドボタン1を押したら、keyWordで検索しようとしていますが、検索してくれません。ユーザーフォームで押したボタンの値をオートフィルターをしようとしています、コードの修正箇所についてご教示ください。
28
28
 
29
- 2.コマンドボタン2を押したら、ユーザーフォームのボタンの値を一度にクリア(初期状態)にする方法を教えてください。
29
+ 2.コマンドボタン2を押したら、ユーザーフォームのボタンの値を一度にクリア(初期状態)にする方法を教えてください。
30
+
31
+ <修正しました>
32
+ ```Private Sub CommandButton1_Click()
33
+ Dim Control1 As Control
34
+ Dim Control2 As Control
35
+ Dim Control3 As Control
36
+ Dim keyWord As String
37
+
38
+ For Each Control1 In Frame1.Controls
39
+ If Control1.Value = True Then Exit For
40
+ Next
41
+ For Each Control2 In Frame2.Controls
42
+ If Control2.Value = True Then Exit For
43
+ Next
44
+ For Each Control3 In Frame3.Controls
45
+ If Control3.Value = True Then
46
+ MsgBox Control1.Caption & "_" & Control2.Caption & "_" & Control3.Caption
47
+ Exit For
48
+ End If
49
+ Next
50
+
51
+ With Sheets("Sheet1").Range("A1")
52
+ .AutoFilter field:=1, Criteria1:=keyWord
53
+ .CurrentRegion.Offset(1, 0).Resize(.CurrentRegion.Rows.Count - 1, 4).Copy
54
+ End With
55
+
56
+ 'Sheet2の2列目の最後の行の下に貼付
57
+ With Sheets("Sheet2").Range("A1").CurrentRegion
58
+ .Cells(.Rows.Count + 1, 1).PasteSpecial
59
+ End With
60
+
61
+ End Sub
62
+ コード
63
+ ```