I have created the following section of code. WHat I am trying to do is just to have it run through the first 8784 rows, not the entire worksheet. I have the "for" statement at the top, but it continues to run through all the rows, slowing the macro down considerably. How do I get it to run just on the rows I want it to. Column A is always filled to row 8784 and I tried to use the "last row" but that did not work either, even though in break mode I could see that it was picking up the last row.
Thanks for any help on this one.
Thanks for any help on this one.
Code:
Sub data_correction()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For Each cell In Sheets("2005").Range("I4:I8784")
If cell.Offset(-2, -8).Value <> "" And cell.Offset(-2, -8).Value = cell.Offset(-2, -2).Value And cell.Offset(-2, -7).Value <> cell.Offset(-2, 0).Value Then
Range(cell.Offset(-2, -6), cell.Offset(-2, 19)).Insert
cell.Offset(-3, 0).Value = cell.Offset(-3, -7).Value
cell.Offset(-3, -2).Value = cell.Offset(-3, -8).Value
Range(cell.Offset(-3, 1), cell.Offset(-3, 19)).Value = "999"
End If
If cell.Offset(-2, -8).Value <> "" And cell.Offset(-2, -8).Value <> cell.Offset(-2, -2).Value Then
Range(cell.Offset(-2, -6), cell.Offset(-2, 19)).Insert
cell.Offset(-3, -2).Value = cell.Offset(-3, -8).Value
cell.Offset(-3, 0).Value = cell.Offset(-3, -7).Value
Range(cell.Offset(-3, 1), cell.Offset(-3, 19)).Value = "999"
End If
Next cell
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub