菜鳥試了一下,不知是不是你想要的, Dim rng As Range If Range('a65536').End(xlUp).Row >= 3 Then Range('a3:c' & Range('a65536').End(xlUp).Row).ClearContents End If For Each rng In Sheets('源數(shù)據(jù)').Range('a5:a' & Sheets('源數(shù)據(jù)').Range('a65536').End(xlUp).Row) If rng >= Sheets('源數(shù)據(jù)').Range('b1') And rng <= Sheets('源數(shù)據(jù)').Range('d1') Then a = Application.Max(Range('a65536').End(xlUp).Row, 2) Cells(a + 1, 1) = rng If Sheets('源數(shù)據(jù)').Cells(rng.Row, 'c') <> 0 Or Sheets('源數(shù)據(jù)').Cells(rng.Row, 'd') <> 0 Then Cells(a + 1, 2) = Application.Max(Sheets('源數(shù)據(jù)').Cells(rng.Row, 'c'), Sheets('源數(shù)據(jù)').Cells(rng.Row, 'd')) Else Cells(a + 1, 2) = '' End If If Sheets('源數(shù)據(jù)').Cells(rng.Row, 'f') > 200 Then Cells(a + 1, 3) = Sheets('源數(shù)據(jù)').Cells(rng.Row, 'f') Else If Sheets('源數(shù)據(jù)').Cells(rng.Row, 'e') <> 0 Then Cells(a + 1, 3) = Sheets('源數(shù)據(jù)').Cells(rng.Row, 'e') Else Cells(a + 1, 3) = '' End If End If End If Next |
|