Hi
I have a large data set which has to be copied and pasted in to an excel-document every day, week and month. But because of GDPR regulations there are some rows that have to be deleted.
In stead of opening the new file every day, filtering manually and then copy/paste, I wrote a macro to do that job for me (posted below).
Now, the macro works fine, but it is really slow, especially when it needs to clean up a week or month with thousands of rows. Seems like it recalculates the whole document for each row it deletes.
Does anyone know how to get the recalculation done at the end when the last row is checked/deleted, or otherwise speed up the process?
Thanks
Mads
I have a large data set which has to be copied and pasted in to an excel-document every day, week and month. But because of GDPR regulations there are some rows that have to be deleted.
In stead of opening the new file every day, filtering manually and then copy/paste, I wrote a macro to do that job for me (posted below).
Now, the macro works fine, but it is really slow, especially when it needs to clean up a week or month with thousands of rows. Seems like it recalculates the whole document for each row it deletes.
Does anyone know how to get the recalculation done at the end when the last row is checked/deleted, or otherwise speed up the process?
VBA Code:
Sub Rydd_rader_1()
Dim Cell As Range, cRange As Range, LastRow As Long, x As Long
LastRow = ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Row
Set cRange = Range("C5:C" & LastRow)
For x = cRange.Cells.Count To 1 Step -1
With cRange.Cells(x)
If .Value <> "Team 1" Then
.EntireRow.Delete
End If
End With
Next x
End Sub
Thanks
Mads
Last edited by a moderator: