![]() OK so now we have the first and last line of our program and a name Step Four - Getting the message Once you understand the editor you will find that you can work with it rather than against it. For example if you don't notice that the editor has added End Sub and you go and add it again. This is great - except when it goes wrong. ![]() This is a general behaviour and the editor will try to help you as much as possible. You may also be surprised to find that VBA adds the brackets at the end of Sub Hello if you leave them off - they just have to be there! Similarly it automatically adds the End Sub once again it is essential - you can't have a Sub without and End Sub so the editor adds them for you. The word hello on the other hand isn’t a VBA keyword because it's up to you what you call a program. To show that it has detected a key word it turns the word blue. This is because they are VBA keywords - a fixed set of commands that VBA recognise. If you enter these lines you will notice that the Sub and End Sub automatically appear in blue and with the correct capitalisation. The final line of the program has to be End SubĪnd leaving this off makes Excel think you haven’t finished your program. Sub is short for Subroutine but more of this later.įor example in our case the program would start Sub hello()Īnd the program would be called hello. Where name is the name you want to give your program. Now we have to enter our first simple program.Īll programs in VBA have to start and end in a particular way.
0 Comments
Leave a Reply. |