Copy with criteria
Juliann
The following will copy from sheet1 to sheet2. I've got data in rows 2:5 and the sum in row 4 is 0. Rows 2,3 and 5 copy, while row 4 does not. You don't specify how you want the output to look, so I've just copied it to the same relative place on sheet2
HT
Ton
Sub aaa(
Sheets("sheet1").Selec
Range("D2").Selec
While Not IsEmpty(ActiveCell
If WorksheetFunction.Sum(Range(ActiveCell.Address), Range(ActiveCell.Offset(0, 4).Address)) 0 The
Range(ActiveCell, ActiveCell.Offset(0, 4)).Copy Destination:=Sheets("sheet2").Cells(ActiveCell.Row , 4
End I
ActiveCell.Offset(1, 0).Selec
Wen
End Su
----- Julianna wrote: ----
I need to copy several lines from 'sheet 1' to sheet 2' that from column D to H that the sum(D:H) is greater than zero
I know this can be done thru filters but the file users of this spreadsheet have very limited Excel knowledge (less than I have :), so I am trying to do it thru VBA
Thanks in advance
Julianna
|