So, creating your first piece of code: Load excel. Make sure there is a worbook loaded. Save it with a name you will remember. Lets say 'tradetest.xls'
Load the VBE editor. (Either go tools -> Macros -> Visual Basic Editor, or press Alt F11)
You should then see the VBE Editor with a menu structure screen on the left showing current projects and current modules. Right click over the VBA Project(tradetest.xls) , click insert, module.
You should now have a screen into which you can enter your code which should look something like this:
Now lets enter our first piece of code. Type the following into the code window:
________________________
Sub test()
'This a test piece of code
MsgBox "hello trader"
End sub
_______________________
Okay, so this not exactly exciting but you have to start somewhere.
To run the code click on the play button on the VB toolbar.
And you should get a message box in excel like this:
Well done, you have cracked your first piece of code.
No comments:
Post a Comment