
7000 years ago, someone picked up a slab of clay, then decided to record a list of expenditures, goods received, goods traded and whatever other pieces of information they wanted.
Humans continued to improve on this for millennia, changing from clay tablets to paper, changing the marking tool to ink. But the results were just a static list of figures.
In 1969, LANPAR was the first electronic spreadsheet - but it resided on a mainframe. Then, in 1976, Jobs, Woz and Wayne founded Apple - which led to VisiCalc in 1979. Then IBM released Lotus 123 in '83, bringing spreadsheet tech to those that used DOS. Finally, in 1985, Microsoft Excel emerged onto the market ('87 for full release).
In 1993, Microsoft added something to Excel that changed my world!!!
Don't get me wrong, other vendors had scripting languages that could talk to their spreadsheet software. But you needed a PhD in computing to use them. The appeal of VBA was it's simplicity. (At least to me)
The only thing I'd like you to do today is open the VBA editor, add a Module, then write the most famous piece of "Canadian" code.
There it is in all it's glory!!!
I will be referring to three sections in the editor. For lack of better terms, I'm going to call these sections the Project pane, the Properties pane and the Code pane.
NOTE: You can also open the VBA editor from the Developer Tab
A VBA module is just a container to write some code.
If you want, you can save the module separately so that you can use it again in other macros. But ... that's for another story.
You can find other methods to insert a module here.
As you write more code, you start reusing your Modules. By default, the modules name is "Modulen"
Typically, the Properties pane is directly below the Project pane. If it is missing, press <F4> to show it.
Then just change the name.
The change should show up instantaneously.
For the first exercise, the code is just going to write "Hello World" to Cell A1 in Excel. The first time that "Hello World" was documented was by the Canadian Brian Kernighan when he worked at Dell Labs.
In the code pane, Copy and Paste this:
Sub helloWorld()
Cells(1, 1) = "Hello World"
End Sub
If you arrange the Excel Spreadsheet next to the VBA Editor, you can watch the spreadsheet when you run your macros.
In the VBA editor, <click> Run, then <click> "Run Sub/Userform"
In your Excel Sheet, you will now see "Hello World"
I hope you find this useful, or that it gives you some ideas for a script of your own.