- 締切済み
EXCELで、ある行のみ抽出したい(マクロ・関数)
- みんなの回答 (1)
- 専門家の回答
みんなの回答
- tom04
- ベストアンサー率49% (2537/5117)
こんばんは! VBAでの一例です。 Sub test() 'この行から Dim i As Long Dim ws1, ws2 As Worksheet Set ws1 = Worksheets("sheet1") Set ws2 = Worksheets("sheet2") ws1.Columns(1).Insert For i = 2 To ws1.Cells(Rows.Count, 2).End(xlUp).Row If ws1.Cells(i, 4) = "A1" Then ws1.Cells(i, 1) = "A1" ElseIf ws1.Cells(i, 4) = "" And ws1.Cells(i - 1, 1) = "A1" Then ws1.Cells(i, 1) = "A1" End If Next i For i = 2 To ws1.Cells(Rows.Count, 2).End(xlUp).Row If ws1.Cells(i, 1) = "A1" And ws1.Cells(i, 2) = "D1" Then With ws2.Cells(Rows.Count, 1).End(xlUp).Offset(1) .Value = ws1.Cells(i, 2) .Offset(, 1) = ws1.Cells(i, 3) .Offset(, 2) = ws1.Cells(i, 4) End With End If Next i ws1.Columns(1).Delete End Sub 'この行まで こんな感じではどうでしょうか?m(_ _)m