| 
    
     |  | ▼koshimizu さん: 以下のコードをお試しください。
 データシート名は"Sheet1"、出力シートは"Sheet2"としています。
 
 Sub test()
 Dim Team As String
 Dim DataSheet As String
 Dim OutputSheet As String
 Dim i As Integer
 Dim j As Integer
 
 '初期設定
 DataSheet = "Sheet1"
 OutputSheet = "Sheet2"
 Sheets(OutputSheet).Cells.ClearContents
 Sheets(OutputSheet).Cells(1, 1) = "番号"
 Sheets(OutputSheet).Cells(1, 2) = "スポーツ"
 Sheets(OutputSheet).Cells(1, 3) = "氏名"
 Sheets(OutputSheet).Cells(1, 4) = "ランク"
 
 Team = InputBox("チーム名の入力")
 i = 1
 j = 2
 Do
 i = i + 1
 If Sheets(DataSheet).Cells(i, 2) = "" Then Exit Do
 If Sheets(DataSheet).Cells(i, 7) = Team Then
 Sheets(OutputSheet).Cells(j, 1) = Sheets(DataSheet).Cells(i, 2)
 Sheets(OutputSheet).Cells(j, 2) = Sheets(DataSheet).Cells(i, 3)
 Sheets(OutputSheet).Cells(j, 3) = Sheets(DataSheet).Cells(i, 4)
 Sheets(OutputSheet).Cells(j, 4) = Sheets(DataSheet).Cells(i, 20)
 j = j + 1
 End If
 Loop
 Sheets(OutputSheet).Select
 
 End Sub
 
 |  |