回答編集履歴
2
コード追加
test
CHANGED
@@ -75,3 +75,19 @@
|
|
75
75
|
End Sub
|
76
76
|
|
77
77
|
```
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
ちなみに、
|
82
|
+
|
83
|
+
```vba
|
84
|
+
|
85
|
+
sh1.Cells(R1, "E") = Left(Mid(rngSearch, InStr(rngSearch, "【") + 1), InStr(Mid(rngSearch, InStr(rngSearch, "【") + 1), "】") - 1)
|
86
|
+
|
87
|
+
```の部分は、下記のように簡略化できます。
|
88
|
+
|
89
|
+
```vba
|
90
|
+
|
91
|
+
sh1.Cells(R1, "E") = Split(Split(rngSearch, "【")(1), "】")(0)
|
92
|
+
|
93
|
+
```
|
1
コード追加
test
CHANGED
@@ -11,3 +11,67 @@
|
|
11
11
|
|
12
12
|
|
13
13
|
[ワイルドカードを使って検索(Find メソッド) \| ExcelWork.info](https://excelwork.info/excel/findwildcard/)
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
上記以外にも、いろいろ間違っていたり、余分なコードがあるので、修正しました。
|
18
|
+
|
19
|
+
修正箇所が多いので、いちいち解説するのは大変なのて、もとコードと見比べて、どこが違っているかご自身で研究してください。
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
```vba
|
24
|
+
|
25
|
+
Sub test()
|
26
|
+
|
27
|
+
Dim sh1 As Worksheet
|
28
|
+
|
29
|
+
Dim rngSearch As Range
|
30
|
+
|
31
|
+
Dim myRange As Range
|
32
|
+
|
33
|
+
Dim strAdr As String
|
34
|
+
|
35
|
+
Dim s As Variant
|
36
|
+
|
37
|
+
Dim R1 As Long, R2 As Long
|
38
|
+
|
39
|
+
On Error Resume Next
|
40
|
+
|
41
|
+
Set sh1 = Worksheets("Sheet1")
|
42
|
+
|
43
|
+
R1 = sh1.Cells(Rows.Count, "E").End(xlUp).Row + 1
|
44
|
+
|
45
|
+
For Each s In ThisWorkbook.Worksheets
|
46
|
+
|
47
|
+
If s.Name <> "Sheet1" Then
|
48
|
+
|
49
|
+
R2 = s.Cells(Rows.Count, "B").End(xlUp).Row
|
50
|
+
|
51
|
+
Set myRange = s.Range(s.Cells(1, "B"), s.Cells(R2, "B"))
|
52
|
+
|
53
|
+
Set rngSearch = myRange.Find(What:="*【*】*", LookAt:=xlWhole, SearchOrder:=xlByColumns)
|
54
|
+
|
55
|
+
If Not rngSearch Is Nothing Then
|
56
|
+
|
57
|
+
strAdr = rngSearch.Address
|
58
|
+
|
59
|
+
Do
|
60
|
+
|
61
|
+
sh1.Cells(R1, "E") = Left(Mid(rngSearch, InStr(rngSearch, "【") + 1), InStr(Mid(rngSearch, InStr(rngSearch, "【") + 1), "】") - 1)
|
62
|
+
|
63
|
+
R1 = R1 + 1
|
64
|
+
|
65
|
+
Set rngSearch = myRange.FindNext(rngSearch)
|
66
|
+
|
67
|
+
Loop While rngSearch.Address <> strAdr
|
68
|
+
|
69
|
+
End If
|
70
|
+
|
71
|
+
End If
|
72
|
+
|
73
|
+
Next
|
74
|
+
|
75
|
+
End Sub
|
76
|
+
|
77
|
+
```
|