Hi there Everyone! I have a macro which deletes rows based on a given criteria. The main point of the macro is that the users should see only data relevant to them. So what I figured out is: that when the user opens the file (and gives the password) based on the given login name and correct password all the rows not related to the user will be deleted.

The macro verifies if in column "F" or "K" is the given value, and if not then deletes the whole row. The macro is working perfectly... but as there are more then 40.000 rows it is very slow, painfully slow. It takes around 20-30 minutes to run. As I am very very new with VBA I am sure that there is a better/faster solution. Please help me if you can! See below my code:

Sub kozepmagyar()

Worksheets(1).Activate
Dim i As Long
i = 1
Do While Cells(i, "a").Value <> ""
If Cells(i, "f").Value <> "Közép-Magyarország" Or Cells(i, "k").Value <> "Közép-Magyarország" Then
 Rows(i).EntireRow.Delete
End If

i = i + 1

Loop

End Sub
Please help if you can!
Thank you in advance!