I need compare current row & next row1, row1 & row2, row2 & row3… last row as below image
And I have to do it manually so many times. How can I use loop ?
DtPhu.Rows(idx+1).Item(2).ToString=DtPhu.Rows(idx+2).Item(2).ToString And Left(DtPhu.Rows(idx+1).Item(1).ToString,6)=Left(DtPhu.Rows(idx+2).Item(1).ToString,6)
Last time you helped me compare row1 & row2 in case Customcode “C00392,C01085,C00600,C01017,C01069”. And compare row1 & row2
(RowPhu.Item(2).ToString=DtPhu.Rows(idx+1).Item(2).ToString) And Left(RowPhu.Item(1).ToString,6)=Left(DtPhu.Rows(idx+1).Item(1).ToString,6)
row2 & row3
DtPhu.Rows(idx+1).Item(2).ToString=DtPhu.Rows(idx+2).Item(2).ToString And Left(DtPhu.Rows(idx+1).Item(1).ToString,6)=Left(DtPhu.Rows(idx+2).Item(1).ToString,6)
Problem: i don’t know how many row to continue compare. So I want ask have other way, can use loop ?
then we are using the n+1 row and compare with the row before that we get with
yourDataTable.Rows(idx)
as the index starts with 0 we fetch always the previous row
However, while looking to your data, representing a lot if duplicates we do feel that the use case maybe target something else. So elaborate more on your initial requirement and what is to achieve.
Maybe grouping the data / duplicate checks can help to reach the goal