|
先ほど質問させて頂いた者ですが、下記のコードを作ってみました。
一応、希望通りの動作はするのですが、Cells(co1 + 2, 17) = Me.Controls("label" & co1).Captionを各月のif文の場所へ追加した結果、動作の速度がかなり遅くなりました。これって仕方ない事なのでしょうか?
まだまだVBAを使い始めて日が浅いもので、コードの書き方等おかしいところも多々あると思いますので、どうぞご指導をお願い致します。
For co1 = 1 To 40
For i = 1 To 400
Select Case i
Case 1 To 10: co = 3: cou = 17
Case 11 To 20: co = 4: cou = 7
Case 21 To 30: co = 5: cou = -3
Case 31 To 40: co = 6: cou = -13
Case 41 To 50: co = 7: cou = -23
Case 51 To 60: co = 8: cou = -33
Case 61 To 70: co = 9: cou = -43
Case 71 To 80: co = 10: cou = -53
Case 81 To 90: co = 11: cou = -63
Case 91 To 100: co = 12: cou = -73
Case 101 To 110: co = 13: cou = -83
Case 111 To 120: co = 14: cou = -93
Case 121 To 130: co = 15: cou = -103
Case 131 To 140: co = 16: cou = -113
Case 141 To 150: co = 17: cou = -123
Case 151 To 160: co = 18: cou = -133
Case 161 To 170: co = 19: cou = -143
Case 171 To 180: co = 20: cou = -153
Case 181 To 190: co = 21: cou = -163
Case 191 To 200: co = 22: cou = -173
Case 201 To 210: co = 23: cou = -183
Case 211 To 220: co = 24: cou = -193
Case 221 To 230: co = 25: cou = -203
Case 231 To 240: co = 26: cou = -213
Case 241 To 250: co = 27: cou = -223
Case 251 To 260: co = 28: cou = -233
Case 261 To 270: co = 29: cou = -243
Case 271 To 280: co = 30: cou = -253
Case 281 To 290: co = 31: cou = -263
Case 291 To 300: co = 32: cou = -273
Case 301 To 310: co = 33: cou = -283
Case 311 To 320: co = 34: cou = -293
Case 321 To 330: co = 35: cou = -303
Case 331 To 340: co = 36: cou = -313
Case 341 To 350: co = 37: cou = -323
Case 351 To 360: co = 38: cou = -333
Case 361 To 370: co = 39: cou = -343
Case 371 To 380: co = 40: cou = -353
Case 381 To 390: co = 41: cou = -363
Case 391 To 400: co = 42: cou = -373
End Select
Worksheets(Mys).Select
If Me.Controls("combobox2").Value = "4月" Then
Cells(co, i + cou) = Me.Controls("CheckBox" & i).Value
If Me.Controls("CheckBox" & i).Value Then
Cells(co, i + cou).Value = "○"
Else
Cells(co, i + cou).Value = "×"
End If
Cells(co1 + 2, 17) = Me.Controls("label" & co1).Caption
ElseIf Me.Controls("combobox2").Value = "5月" Then
Cells(co, i + cou + 12) = Me.Controls("CheckBox" & i).Value
If Me.Controls("CheckBox" & i).Value Then
Cells(co, i + cou + 12).Value = "○"
Else
Cells(co, i + cou + 12).Value = "×"
End If
Cells(co1 + 2, 29) = Me.Controls("label" & co1).Caption
ElseIf Me.Controls("combobox2").Value = "6月" Then
Cells(co, i + cou + 24) = Me.Controls("CheckBox" & i).Value
If Me.Controls("CheckBox" & i).Value Then
Cells(co, i + cou + 24).Value = "○"
Else
Cells(co, i + cou + 24).Value = "×"
End If
Cells(co1 + 2, 41) = Me.Controls("label" & co1).Caption
End If
Next i
Next co1
|
|