複数のシートを結合後に、特定の列が空白、0、数値以外の行を削除する。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
Sub Cp() For Each w In Sheets If w.Name = "集計" Then Sheets("集計").Delete Next w Sheets.Add Before:=Sheets(1) ActiveSheet.Name = "集計" For Each w In Worksheets If w.Name <> "集計" Then If Sheets("集計").UsedRange.Rows.Count = 1 Then r = 1 Else r = Sheets("集計").UsedRange.Rows.Count + 1 End If w.UsedRange.Copy Sheets("集計").Cells(r, 1).PasteSpecial Paste:=xlPasteValues Sheets("集計").Cells(r, 1).PasteSpecial Paste:=xlPasteFormats Application.CutCopyMode = False w.UsedRange.ClearContents End If Next w c = 19 '判断列 k = 2 For i = 1 To Sheets("集計").UsedRange.Rows.Count Application.StatusBar = "削除中 ... " & i If Sheets("集計").Cells(k, c).Value = "" Or Sheets("集計").Cells(k, c).Value = 0 Or IsNumeric(Sheets("集計").Cells(k, c).Value) = False Then Sheets("集計").Rows(k).Delete Else k = k + 1 End If Next i For Each w In Sheets If w.Name <> "集計" Then w.Delete Next w Application.StatusBar = False MsgBox "done" End Sub |