Sub CopyData()
Dim rng as range, rng1 as Range, cell as range
set rng = Range(cells(2,1),cells(rows.count,1).End(xlup))
for each cell in rng
if abs(abs(cells(cell.row,"K"))-abs(Cells(cell.row,"O"))) < .000001 then
if rng1 is nothing then
set rng1 = cell
else
set rng1 = union(rng1,cell)
end if
end if
Next
if not rng1 is nothing then
rng1.EntireRow.copy worksheets("Sheet2").Range("A1")
rng1.EntireRow.Delete
end if
End Sub
test it on a copy of your data. adjust sheet names to reflect yours. Run
the macro with the sheet with the data as the activesheet.
--
Regadrs,
Tom Ogilvy
"Mandeep Dhami" wrote:
> Hello,
>
> I have data in excel with columns from A:T and about 100+ rows.
>
> I need a macro which finds out difference between column 'K' and column 'O'
> and if the difference is ZERO cuts the data from existing worksheet and
> copies it over to new worksheet in same file. The same row by row comparison
> should be done for all the rows in the data.
>
> Let me know if it is possible to do such through macro. If you can provide
> me the email id, I can forward the same in soft copy as well.
>
> Cheers,
> Mandeep Dhami
>
|