回答編集履歴

3

追記

2021/01/29 00:39

投稿

radames1000
radames1000

スコア1925

test CHANGED
@@ -15,3 +15,61 @@
15
15
  ORならこちらが参考になるでしょうか。
16
16
 
17
17
  [オートフィルタで複数列をORで絞り込む](http://officetanaka.net/excel/function/tips/tips82.htm)
18
+
19
+
20
+
21
+ ---
22
+
23
+ ```vba
24
+
25
+ Sub test()
26
+
27
+
28
+
29
+ Dim LastRow As Long
30
+
31
+ Dim LastCol As Long
32
+
33
+ Dim nmField As Long
34
+
35
+ Dim str As String '条件
36
+
37
+ str = "*" & Worksheets("Sheet5").Range("H1") & "*"
38
+
39
+
40
+
41
+ ActiveSheet.AutoFilterMode = False
42
+
43
+
44
+
45
+ LastRow = Cells(Rows.Count, 2).End(xlUp).Row
46
+
47
+ LastCol = Cells(2, Columns.Count).End(xlToLeft).Column
48
+
49
+ If Cells(2, LastCol) = "判定" Then
50
+
51
+ Columns(LastCol).Delete
52
+
53
+ LastCol = LastCol - 1
54
+
55
+ End If
56
+
57
+ Cells(2, LastCol + 1) = "判定"
58
+
59
+ Dim i As Long
60
+
61
+ For i = 3 To LastRow
62
+
63
+ Cells(i, LastCol + 1) = WorksheetFunction.CountIf(Range(Cells(i, 2), Cells(i, LastCol)), str)
64
+
65
+ Next
66
+
67
+ nmField = Range("B2").CurrentRegion.Columns.Count
68
+
69
+ Range("B2").AutoFilter Field:=nmField, Criteria1:=">0"
70
+
71
+
72
+
73
+ End Sub
74
+
75
+ ```

2

OR追記

2021/01/29 00:39

投稿

radames1000
radames1000

スコア1925

test CHANGED
@@ -9,3 +9,9 @@
9
9
  Range("B2").AutoFilter Field:=3, Criteria1:="*"&Worksheets("Sheet5").Range("H1")&"*"
10
10
 
11
11
  ```
12
+
13
+ ---
14
+
15
+ ORならこちらが参考になるでしょうか。
16
+
17
+ [オートフィルタで複数列をORで絞り込む](http://officetanaka.net/excel/function/tips/tips82.htm)

1

誤記修正

2021/01/28 07:55

投稿

radames1000
radames1000

スコア1925

test CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  ```vba
4
4
 
5
- Range("B2").AutoFilter Filed:=2, Criteria1:="*"&Worksheets("Sheet5").Range("H1")&"*"
5
+ Range("B2").AutoFilter Field:=2, Criteria1:="*"&Worksheets("Sheet5").Range("H1")&"*"
6
6
 
7
7
  Range("B2").AutoFilter
8
8
 
9
- Range("B2").AutoFilter Filed:=3, Criteria1:="*"&Worksheets("Sheet5").Range("H1")&"*"
9
+ Range("B2").AutoFilter Field:=3, Criteria1:="*"&Worksheets("Sheet5").Range("H1")&"*"
10
10
 
11
11
  ```