Nick's step by step guide to learn VBA

Nick's picture

Learning VBA is all about building on a few fundamentals. Once you've started, it gets a lot easier. This VBA Training section will teach you those VBA fundamentals.

Hundreds of New VBA Training Videos added here

 

IMPORTANT: Worried about SECURITY? Open Excel in SAFE MODE, examine the VBA, and if you're happy, open Excel normally


Further reading:

AttachmentSize
LearnVBA_Lesson1.xls30 KB
LearnVBA_Lesson3.xls31.5 KB
record-macro-excel.xls30.5 KB
record-macro-VBA.xls28.5 KB

Jay

I went in and played with Offset, etc. and understand everything but one. Why is maxWeight = 0 in the code?

Nick's picture

maxweight

that's what it's initialised to...

Nick's picture

1. Learn VBA - Introduction to VBA Editor

Excel 2007:

Lesson 1 will teach you how to attach some code to a button that will bring up a message box that says Hello!.

Step1:
Make sure your excel options (Office button in top left => Excel Options) are as shown:
Data

Step2:
Click Developer ribbon, Insert => choose the first button under "Form Controls".
Click and hold anywhere on your worksheet. Now drag the mouse down and across slightly. This will create the button. The further you drag, the bigger the button.

Step3:
When the following box pops up, type: myMessageBox in the macro name field.
Data
Now press NEW

Step4:
You will now see a sub routine has been created for you, and you can type the following in the space provided:
MsgBox "Hello!"
Data

Now press ALT + F11 to return to your sheet, and press the button.

Congratulations on writing your first VBA program !

Excel 2003:
Right click on an empty space on the toolbar, and choose FORMS.
...goto Step2 and continue.

Download Practise Sheet

It is really very much

It is really very much interesting...

Didn't work

Every time I type myNewMessage in it shows me an edit button and not a "New" button. It has the message that you said to type but when I press alt +f11 it doesn't work. It will allow me to press it but nothing happens. any help? I have office 2007

RE: Didn't work

Hello,

Possible problem: you are download a practice file and when you try to type myMessageBox you see Edit button, not New, because there is already have a subroutine with that name.

When press the button and nothing happens, the possible reason is that your macros are disable. Check your macro settings from Excel Options->Trust Center->Trust Center Settings->Macro Settings.

If I'm guess the problem, just open a new excel file and make the exercise step by step once again and it will work.

 

Best regards.

Thanks

Thanks... I was trying to learn Exce Macro for long time..but this helped me to get started
Its easy the way u explained. thanks Hoe for more support

THX!

Easily Learn thanku So Much!

Force this button to be on top of all appications

Hi nick , i saw this button example given by you ..
Is there anyway we can force this button(only not excel) to be on top on all other applications, even the excel is minimised.

Thans
Ruth

Big thank you.

This is my first macro and I am excited to see "Hello!!" on my screen.

Thank you.