Buy a book on VBA.
Take a class.
Read VBA code that has already been written.
Go thru Microsoft tutorials and Help files.
It helps to have a mentor that you can go to when you get stuck (or use
these forums)
I found that for me the most effective way of learning to write code was to
look at an actual piece of code in a functional database with a known result
and look at the logic and terminology that was used to achieve that result.