How to get row index if Excel has duplicate row

What should I write in write range cell values for each of the rows , it should be dynamic?