hello guys,
see above image, actually i want to extract last two row from this sheet and save in another sheet.
and it will be dynamic so that when i added new row below after that i get same output like row 10, and 11
Read Range
newDataTable = yourDataTable.AsEnumerable().Skip(Math.Max(0, yourDataTable.Rows.Count - 2)).CopyToDataTable()
Write Range
Try this
dt_Input.AsEnumerable().Skip(dt_Input.Rows.Count - 2).Take(2).CopyToDataTable()
Input:

Output:

please show me the variable name
Skip(dt_Input.Rows.Count - 2).Take(2)
please explain this
.Skip(dtInput.Rows.Count - 2): Skips the rows before the last two rows.
.Take(2): Takes the next two rows after skipping.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.

