質問編集履歴

1

コードの位置を調整しました

2018/09/14 05:20

投稿

onionion
onionion

スコア13

test CHANGED
File without changes
test CHANGED
@@ -52,7 +52,7 @@
52
52
 
53
53
  ```vba
54
54
 
55
- Sub Macro3()
55
+ Sub 並び替え()
56
56
 
57
57
  Dim i As Integer
58
58
 
@@ -88,59 +88,65 @@
88
88
 
89
89
 
90
90
 
91
- Do
91
+ Do
92
92
 
93
- 'A5~
93
+ 'A5~
94
94
 
95
- 'このあたりは問題なさそうです。
95
+ 'このあたりは問題なさそうです。
96
96
 
97
- If Range("A" & j).Value <> "" Then
97
+ If Range("A" & j).Value <> "" Then
98
98
 
99
- Range("A" & j & ":O" & i).Select
99
+ Range("A" & j & ":O" & i).Select
100
100
 
101
- ThisWorkbook.Worksheets(sh).Sort.SortFields.Clear
101
+ ThisWorkbook.Worksheets(sh).Sort.SortFields.Clear
102
102
 
103
- ThisWorkbook.Worksheets(sh).Sort.SortFields.Add Key:=Range( _
103
+ ThisWorkbook.Worksheets(sh).Sort.SortFields.Add Key:=Range( _
104
104
 
105
- "D" & j & ":D" & i), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
105
+ "D" & j & ":D" & i), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
106
106
 
107
- xlSortTextAsNumbers
107
+ xlSortTextAsNumbers
108
108
 
109
- ThisWorkbook.Worksheets(sh).Sort.SortFields.Add Key:=Range( _
109
+ ThisWorkbook.Worksheets(sh).Sort.SortFields.Add Key:=Range( _
110
110
 
111
- "H" & j & ":H" & i), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
111
+ "H" & j & ":H" & i), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
112
112
 
113
- xlSortNormal
113
+ xlSortNormal
114
114
 
115
- With ThisWorkbook.Worksheets(sh).Sort
115
+
116
116
 
117
- .SetRange Range("A" & j - 1 & ":O" & i)
117
+ With ThisWorkbook.Worksheets(sh).Sort
118
118
 
119
- .Header = xlYes
119
+ .SetRange Range("A" & j - 1 & ":O" & i)
120
120
 
121
- .MatchCase = False
121
+ .Header = xlYes
122
122
 
123
- .Orientation = xlTopToBottom
123
+ .MatchCase = False
124
124
 
125
- .SortMethod = xlPinYin
125
+ .Orientation = xlTopToBottom
126
126
 
127
- .Apply
127
+ .SortMethod = xlPinYin
128
128
 
129
- End With
129
+ .Apply
130
130
 
131
- j = i + 2
131
+ End With
132
132
 
133
+
134
+
135
+ j = i + 2
136
+
133
- i = Cells(j, 1).End(xlDown).Row
137
+ i = Cells(j, 1).End(xlDown).Row
134
138
 
135
139
 
136
140
 
137
- Else
141
+ Else
138
142
 
139
- Exit Do
143
+ Exit Do
140
144
 
141
- End If
145
+ End If
142
146
 
147
+
148
+
143
- Loop
149
+ Loop
144
150
 
145
151
  'ここまでは問題なさそうです。
146
152
 
@@ -154,9 +160,11 @@
154
160
 
155
161
  Else
156
162
 
157
- Exit Do
163
+ Exit Do
158
164
 
159
165
  End If
166
+
167
+
160
168
 
161
169
  Loop
162
170