So it pays to have a collection of useful VBA macro codes that you can have in your back pocket and use it when needed. Also macro recorder has some limitations.
However, that code by macro recorder is often full of code that is not really needed.
One way of getting the VBA code is to record the macro and take the code it generates. Using Excel Macros can speed up work and save you a lot of time.