Hi all
I have workbook with 4 sheets("datanew", "dataold","higher", "lower"), now I want to find higher/lower value then copy to sheets("higher/lower") with conditions that:
Please help me to do this with VBa code or Pivot table, many thanks./.
I have workbook with 4 sheets("datanew", "dataold","higher", "lower"), now I want to find higher/lower value then copy to sheets("higher/lower") with conditions that:
Code:
With sheets("datanew")
lastrow = .Cells(Rows.Count, 12).End(xlUp).Row
lastcolumn = .Cells(1, Columns.Count).End(xlToLeft).Column
for i =3 to lastrow
for j =21 to lastrow
if .cells(i,12).value + .cells(i,13).value < .cells(i,j).value then
sheets("higher").range(A).value = .cells(1,j).value
sheets("higher").range(B).value = .cells(i,j).value
else
if .cells(i,12).value - .cells(i,13).value > .cells(i,j).value then
sheets("lower").range(A).value = .cells(1,j).value
sheets("lower").range(B).value = .cells(i,j).value
end if
next j
next i
End with
Please help me to do this with VBa code or Pivot table, many thanks./.
Last edited: