Find and copy the row using VBA
I assume 4 months was representative and not definitive since none of your
sample data fits that pattern. So I will assume that if the leftmost row is
zero and the rightmost is 0 then copy the row.
Sub CopyData()
Dim rw as Long, cell as Long
Dim rng as Range
With Worksheets("Sheet1")
set rng = .Range(.Range("A2"),.Range("A2").End(xldown))
End With
rw = 2
for each cell in rng
if cell.Value = 0 and cell.offset(0,7).Value 0 then
cell.Resize(1,8).copy Destination:=Worksheets("Sheet2") _
.cells(rw,1)
rw = rw + 1
end if
Next
End Sub
--
Regards,
Tom Ogilvy
"Lolly" wrote in message
...
Hi,
all
I have a data like this
COlA COlB COlC
COLD --------------------------
5-Jun 5-Jul 5-Aug 5-Sep 5-Oct 5-Nov 5-Dec 6-Jan
566.2 676.6 701.1 588.8 623.7 780.4 791.3 479.6
13.7 15 17.5 15.5 12.2 13.7 15.1 9.3
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
5 5.9 6.6 5.5 4.1 4 4.8 3.5
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
5 5.9 6.6 5.5 4.1 4 4.8 3.5
6.1 6.6 7.4 6.7 5 5.1 5.6 4.8
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
6.1 6.6 7.4 6.7 5 5.1 5.6 4.8
1.1 1.1 1.8 1.6 1.6 2.7 2.9 1.1
0 0 0 0 0 1.7 1.4 0
0 0 0 0 0 0 0 0
it's a huge data. I need to find and copy the row in another sheet which
contains the data like this
For four months it's zero and then it has some data. It's usually done for
tracking new product.
0 0 0 0 12.5
any help would be appreciated.
Thanks a lot
--
Kittie
|