Enable the Developer Tab: Go to “File” > “Options” > “Customize Ribbon” > Check “Developer” > Click “OK.”
Open VBA Editor: On the Developer tab, click “Visual Basic” or press
Alt + F11.
Create a New Macro Module: In the VBA Editor, click “Insert” > “Module” to create a new module.
Write the Macro: Type your VBA code in the module to record the actions you want the macro to perform.
Save the Macro: Close the VBA Editor, and your macro will be saved in the document automatically.
Run the Macro: To use the macro, go to the Developer tab > Click “Macros” > Select your macro > Click “Run.”