Excel - How to open the VBA Editor by gikitiki

View this thread on steempeak.com
· @gikitiki ·
$0.55
Excel - How to open the VBA Editor
![XLVBA](https://steemitimages.com/0x0/https://cdn.steemitimages.com/DQmSVvLR5W7SiYqcRQSEfAJmSbomcnmVdYPKiCYxBnuQYGG/XLVBA.gif)

<hr>

<h1> History is Fun - honest </h1>

<h2>    In the beginning, there were ledgers.   </h2>

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.

<h2> Then there was a spreadsheet </h2>

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!!!

<h2> Visual Basic for Applications (VBA) was born </h2>

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)

<h1> How to open the VBA Editor </h1>

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.

<h2> The easiest way to open the VBA editor is... </h2>
- Open Excel
- Press \<Alt\>\<F11\>

![image.png](https://cdn.steemitimages.com/DQmVEP9cDGrJ4nUxoLsYmiGjxjWq4zGFQv7QEsknLXLh3Dg/image.png)

<em>There it is in all it's glory!!! </em>

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.

![image.png](https://cdn.steemitimages.com/DQmR8cJtz977wUj5DNiaCnZyUmKh9fU7pougQEccJMxdZrt/image.png)


NOTE:  You can also open the VBA editor from the [Developer Tab](https://www.techonthenet.com/excel/questions/developer_tab2013.php)

<h1> How to Add a Module </h1>

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.

<h2>  An Easy way to insert a Module </h2>

- In the VBA Editor, \<click\> on Insert, then click on \<Module\>

![image.png](https://cdn.steemitimages.com/DQmQR2dAbTbV9xLdYyYp3qZeXpSYkj9QTDmrEX6XxwV6qmn/image.png)

<sub>You can find other methods to  insert a module [here](https://lmgtfy.com/?q=vba+ways+to+insert+a+module).  </sub>

- In the Project Explorer, you should now see your Module

![image.png](https://cdn.steemitimages.com/DQmT4tuwXWxDbhtzGpJqEWXYUhHjja1byc7ReT383SSpYAh/image.png)


<h2> Once you have inserted a Module, I recommend you name it to something useful </h2>

As you write more code, you start reusing your Modules.  By default, the modules name is "Module<sub>n</sub>"

Typically, the <em>Properties</em> pane is directly below the <em>Project</em> pane.  If it is missing, press \<F4\> to show it. 

![image.png](https://cdn.steemitimages.com/DQmWRfjVV76hFKn8YUJxnSmXimBqhBtbAPFEUxCPWhvk1gN/image.png)

Then just change the name.

![image.png](https://cdn.steemitimages.com/DQmWnQAj6P6AabXTjPynagvoqLTckiKT8Q7QuwYRTzs8tqP/image.png)

The change should show up instantaneously.


![image.png](https://cdn.steemitimages.com/DQmWnQ4qTxucXtfAsLuFFChmugTNRnvrwqBu7ua3nr7GjKt/image.png)


<h1> Write a little Code </h1>

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](https://en.wikipedia.org/wiki/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
```

<h1> Watch the Magic </h1>

If you arrange the Excel Spreadsheet next to the VBA Editor, you can watch the spreadsheet when you run your macros.


![image.png](https://cdn.steemitimages.com/DQmbQzLGuRv6s52eLovYTBD5KeEv8HTvRfWPwzyRF3iRqFf/image.png)

In the VBA editor, \<click\> Run, then \<click\> "Run Sub/Userform"


![image.png](https://cdn.steemitimages.com/DQmerZ1SHbtw5K3fS7xVFd8xT3VxGTFPHXWWGT5XpPstCMB/image.png)

In your Excel Sheet, you will now see "Hello World"


![image.png](https://cdn.steemitimages.com/DQmdrrwgbkAD1bNQU1dGa2FjkeAGgwLtsguPG7iVN7N2jmq/image.png)

<h1> That's all for now </h1>

<hr>

I hope you find this useful, or that it gives you some ideas for a script of your own.
πŸ‘  , , , , , , , , , , , , ,
πŸ‘Ž  
properties (23)
post_id82,684,878
authorgikitiki
permlinkexcel-how-to-open-the-vba-editor
categoryhive-102332
json_metadata{"tags":["excel","vba"],"image":["https:\/\/steemitimages.com\/0x0\/https:\/\/cdn.steemitimages.com\/DQmSVvLR5W7SiYqcRQSEfAJmSbomcnmVdYPKiCYxBnuQYGG\/XLVBA.gif","https:\/\/cdn.steemitimages.com\/DQmVEP9cDGrJ4nUxoLsYmiGjxjWq4zGFQv7QEsknLXLh3Dg\/image.png","https:\/\/cdn.steemitimages.com\/DQmR8cJtz977wUj5DNiaCnZyUmKh9fU7pougQEccJMxdZrt\/image.png","https:\/\/cdn.steemitimages.com\/DQmQR2dAbTbV9xLdYyYp3qZeXpSYkj9QTDmrEX6XxwV6qmn\/image.png","https:\/\/cdn.steemitimages.com\/DQmT4tuwXWxDbhtzGpJqEWXYUhHjja1byc7ReT383SSpYAh\/image.png","https:\/\/cdn.steemitimages.com\/DQmWRfjVV76hFKn8YUJxnSmXimBqhBtbAPFEUxCPWhvk1gN\/image.png","https:\/\/cdn.steemitimages.com\/DQmWnQAj6P6AabXTjPynagvoqLTckiKT8Q7QuwYRTzs8tqP\/image.png","https:\/\/cdn.steemitimages.com\/DQmWnQ4qTxucXtfAsLuFFChmugTNRnvrwqBu7ua3nr7GjKt\/image.png","https:\/\/cdn.steemitimages.com\/DQmbQzLGuRv6s52eLovYTBD5KeEv8HTvRfWPwzyRF3iRqFf\/image.png","https:\/\/cdn.steemitimages.com\/DQmerZ1SHbtw5K3fS7xVFd8xT3VxGTFPHXWWGT5XpPstCMB\/image.png","https:\/\/cdn.steemitimages.com\/DQmdrrwgbkAD1bNQU1dGa2FjkeAGgwLtsguPG7iVN7N2jmq\/image.png"],"links":["https:\/\/www.techonthenet.com\/excel\/questions\/developer_tab2013.php","https:\/\/lmgtfy.com\/?q=vba+ways+to+insert+a+module","https:\/\/en.wikipedia.org\/wiki\/Brian_Kernighan"],"app":"steemit\/0.2","format":"markdown"}
created2019-12-19 17:10:45
last_update2019-12-19 17:10:45
depth0
children4
net_rshares2,657,175,812,571
last_payout2019-12-26 17:10:45
cashout_time1969-12-31 23:59:59
total_payout_value0.277 SBD
curator_payout_value0.276 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length4,658
author_reputation8,799,225,435,691
root_title"Excel - How to open the VBA Editor"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (15)
@steemitboard ·
Congratulations @gikitiki! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

<table><tr><td><img src="https://steemitimages.com/60x70/http://steemitboard.com/@gikitiki/votes.png?201912212221"></td><td>You distributed more than 41000 upvotes. Your next target is to reach 42000 upvotes.</td></tr>
</table>

<sub>_You can view [your badges on your Steem Board](https://steemitboard.com/@gikitiki) and compare to others on the [Steem Ranking](https://steemitboard.com/ranking/index.php?name=gikitiki)_</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>



###### [Vote for @Steemitboard as a witness](https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1) to get one more award and increased upvotes!
πŸ‘  
properties (23)
post_id82,741,166
authorsteemitboard
permlinksteemitboard-notify-gikitiki-20191221t230417000z
categoryhive-102332
json_metadata{"image":["https:\/\/steemitboard.com\/img\/notify.png"]}
created2019-12-21 23:04:18
last_update2019-12-21 23:04:18
depth1
children0
net_rshares4,123,863,044
last_payout2019-12-28 23:04:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length850
author_reputation38,705,954,145,809
root_title"Excel - How to open the VBA Editor"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (1)
@theexcelclub ·
thanks for the post, yes it is indeed useful.  Excel changed my world too and for years I managed without VBA.  But now I think I gotta learn it :-)
πŸ‘  
properties (23)
post_id82,765,071
authortheexcelclub
permlinkq2xn6o
categoryhive-102332
json_metadata{"app":"steemit\/0.2"}
created2019-12-22 21:18:24
last_update2019-12-22 21:18:24
depth1
children0
net_rshares4,115,802,049
last_payout2019-12-29 21:18:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length148
author_reputation40,220,220,244,131
root_title"Excel - How to open the VBA Editor"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (1)
@gadrian · (edited)
$0.06
Nice... It's been a while since I coded using VBA.

All Office apps support VBA, not just Excel. I once had a project that automatized generating Excel, Word and text files that were before filled in manually.
πŸ‘  , ,
properties (23)
post_id82,896,708
authorgadrian
permlinkq37r0s
categoryhive-102332
json_metadata{"app":"steemit\/0.2"}
created2019-12-28 08:17:18
last_update2019-12-28 08:19:15
depth1
children1
net_rshares379,516,681,961
last_payout2020-01-04 08:17:18
cashout_time1969-12-31 23:59:59
total_payout_value0.032 SBD
curator_payout_value0.032 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length209
author_reputation36,400,815,307,582
root_title"Excel - How to open the VBA Editor"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (3)
@gikitiki ·
$0.04
Excellent!

I’ll get to the other Office tools using VBA in future posts.  For now, I want to focus on Excel. I think it’s most folks comfort zone.  

<hr>


When it comes to programming. The flexibility is  endless. 

I have used Excel to call SAP BAPI’s,  parse the return, then send to MSSQL. Use SQL to insert, create and update. Then finally pass to an Oracle Agile API. 

Your imagination is the limit!!
πŸ‘  
properties (23)
post_id82,913,714
authorgikitiki
permlinkq38kbi
categoryhive-102332
json_metadata{"app":"steemit\/0.1"}
created2019-12-28 18:50:06
last_update2019-12-28 18:50:06
depth2
children0
net_rshares234,360,337,904
last_payout2020-01-04 18:50:06
cashout_time1969-12-31 23:59:59
total_payout_value0.019 SBD
curator_payout_value0.019 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length409
author_reputation8,799,225,435,691
root_title"Excel - How to open the VBA Editor"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (1)