| 
    
     |  | いつも参考にさせてもらっています。 
 このような集計マクロを作ったのですが9サイクル実行させると
 コマンドボタンが消えてしまいます。(コマンドボタンで実行させています)
 なぜだか解りません。
 教えて下さい。
 
 Option Explicit
 
 Public Sub Macro1()
 
 Dim Rng As Range
 Dim IntIndex As Integer
 Dim Cnt As Long
 Dim IntLot As Integer
 Dim StrCood As String
 Dim ID As Integer
 
 Worksheets("sheet1").Range("A2:A15").Clear
 Worksheets("sheet1").Range("B2:Y15").Clear
 
 Application.ScreenUpdating = False
 ID = Worksheets("Sheet1").Range("A19")
 Worksheets("Sheet2").Activate
 Range(Cells(2, ID), Cells(15, ID)).Copy
 ActiveWorkbook.Worksheets("sheet1").Range("A2").PasteSpecial (xlPasteValues)
 
 IntLot = 1
 Do While 1
 IntIndex = 2
 Do While 1
 StrCood = Range("A" & IntIndex)
 If StrCood = "" Then Exit Do
 Set Rng = _
 Worksheets("Sheet1").Range("B20").CurrentRegion
 With Rng
 .AutoFilter Field:=2, Criteria1:=IntLot
 .AutoFilter Field:=6, Criteria1:=StrCood
 Cnt = .Columns(1).SpecialCells(xlCellTypeVisible) _
 .Cells.Count - 1
 Worksheets("Sheet1").Cells(IntIndex, IntLot + 1) = Cnt
 IntIndex = IntIndex + 1
 .AutoFilter
 End With
 Loop
 IntLot = IntLot + 1
 If IntLot > 24 Then Exit Do
 Loop
 Set Rng = Nothing
 Worksheets("Sheet1").Activate
 Application.ScreenUpdating = True
 
 End Sub
 
 |  |