until yesterday the below code was workig fine but today I'm getting a error message Argument out of exception & index out of range. 

Wha t i'm tryring to do here, from the `index 3(4th col)` of the last row, take that cell value & put in to the `col 3 (index 2) cell`. When i type it in the last cell (from bottom to top), i'm getting the above error message.

Please help me.

```
private void datagridview_CellValidated(object sender, CellValidatedEventArgs e)
{

if (e.ColumnIndex != 3)
    return;
int nextRowIndex = e.RowIndex -1;
int lastRowIndex = datagridview.Rows.Count;
try
{

        if (nextRowIndex <= lastRowIndex)
        {
            var valuesForcell = datagridview.Rows[e.RowIndex].Cells[3].Value.ToString();
            datagridview.Rows[nextRowIndex].Cells[2].Value = valuesForcell;
            datagridview.Rows[nextRowIndex].Cells[2].ReadOnly = true;
            datagridview.Rows[nextRowIndex].Cells[2].Style.ForeColor = Color.MediumVioletRed;
            datagridview.ClearSelection();
            datagridview.SelectionMode = GridViewSelectionMode.CellSelect;
            datagridview.Rows[nextRowIndex].Cells[3].BeginEdit();

        }

}
catch (Exception exception) { }

}

```

![enter image description here](https://i.stack.imgur.com/adoRd.jpg)
![enter image description here](https://i.stack.imgur.com/1tAsg.jpg)