I documented a lot of the code already, and I can explain a little more, but unfortunately, I really cannot condense a whole course on VBA in a few short posts here (and that is not what this site is really intended for). In that case, I would highly recommend picking up an introductory VBA code, like this one here:
Microsoft Excel 2019 VBA and Macros
The "Dim" stated are declaring your variables before using them. This helps, especially with debugging your code, in two main ways:
1. Restrict the data that you can put in the variables. So, if you tried to put a text value in a variable that was set up to be an Integer, you would get an error.
2. When used with "Option Explicit", it can help detect typos in your variables.
See here:
VBA Option Explicit | How to Use Option Explicit Statement in Excel VBA?
What the following line does:
VBA Code:
Application.ScreenUpdating = False
is temporarily suspend all screen updates made by the result of your code running. You typically see this near the beginning of the code.
And then you typically see a line like this near the end of the code:
VBA Code:
Application.ScreenUpdating = True
this turns screen updating back on.
So by using these two lines like this, is suspend all screen updates until the very end of the code, and do them all at once. By waiting until the end of the code to do this, and to do it all at once, it speeds up your code,
I think the rest of the code is documented, so hopefully those things are obvious.
If you have any other specific questions, please let me know.