Showing posts with label Visual Basic Editor. Show all posts
Showing posts with label Visual Basic Editor. Show all posts

Wednesday, September 14, 2022

How to insert and start writing VBA code.

Before started module must be insert as below.

  • Open Visual Basic Editor(VBE) by pressing Alt + F11 or read here for more detail.
  • Click insert Tab follow by module.

  • Default inserted Module name Module1..2..3 and etc.
    (Module can be rename later by accessing their property)


    My default setting every module inserted with Option Explicit declaration will explain later.

There are 2 ways to start writing VBA code.

  • Direct type in Sub>Space>Macro Name>Open Bracket>Close Bracket and hit enter
    Ex. Sub My1StVBACode() and hit enter automatically End Sub appeared as below.


    Now we can start writing any code or copy code given and paste here.
    OR
  • Click insert Tab follow by Procedure.

  • Key in My1StVBACode inside Name Box and click OK.


    Let default setting for the rest and will be explain later.
  • The procedure appeared as below.

Note:

  1. Sub is equal to Public Sub and can be called from anywhere.
  2. This is Called procedure and listed under macro name when run macro.

Microsoft Reference - Sub Statement

Practice makes perfect. Thank You.

Thursday, August 18, 2022

How to open Visual Basic Editor under Microsoft Excel?

Visual Basic Editor (VBE) is the place to write and store all Visual Basic code and Macro recorded code. This VBE attached to all office application for example Microsoft Word, Microsoft PowerPoint and etc. but in this blog our focus only VBE in Microsoft Excel. To open this VBE:

Two ways to open Visual Basic Editor in Excel:

  1. 1st Method: Under Developer tab click at Visual Basic.









    Click here if Developer tab is not visible.

  2. 2nd Method: Short cut key by Pressing Alt + F11 button.

  3. Visual Basic Editor will open as below:



















 

Practice makes perfect. Thank You.

Thursday, August 5, 2010

Get to know your VBE (Visual Basic Editor)

VBE or Visual Basic Editor is an application attached to Microsoft Office like Excel, Word and Power point. This is where we kept our coding for each macro recorded. That why before we get started to write your own macro you must be able to use this application. Actually this application same as like any other office application, layout, button, function and etc except this application is design to suit the purpose as a programming tools. As a programming tools of course there must have form (interface design), module (code storage), debugging and etc. To open this as usual :
  1. Open your new excel file
  2. Under Tools menu Click on Macro then Macros
  3. Click on Visual Basic Editor
Click here to learn how to open visual basic editor

Therefore you must learn how to use this application before get started and below items you must know first as well as others:
  1. Project Explorer
    If you open blank excel and open your VBE at your left pane you will see Project – VBAProject, Under this you will be able to see folder list VBAProject(Book1) follow by Microsoft Excel Objects.


    Before recording no modules under project explorer.

  2. Modules
    This is where your coding to be kept after recording or to write your on your own.


    After recording modules appeared.
    Note : Click on modules folder if you unable to see module1
Just play around with VBE then later you will get familiar because others function almost similar with others office application.
Good Luck.

Click here if you have any new project! Let us create for u for free.
Thanks

Thursday, July 22, 2010

How open visual basic editor (VBE) in Excel?

After recording and playback as many as you like for sure you wanted to know what code behind so that you do the editing and write your own code to suit your needs. In order to do that we must know how open visual basic editor (VBE) from excel. There are many ways to do that:
  1. Use short cut key by pressing Alt + F11
  2. Point to Macro on the Tools menu and select Visual Basic Editor



  3. Click Visual Basic Editor Icon at Toolbar (As below image)



Now the editor is open.



Normally you won't be able to see the code immediately because still hiding under Modules folder. Now double click this folder you will see module1 or just click at plus sign beside this folder. Click this module1 and now you will see the code as below:



The above code example is from our previous macro recorded. The process as below:
  • Select Range A1
  • Fill with Red colored
  • Select Range A2
  • Fill with Green colored
  • Select Range A3
  • Fill with Blue colored
  • Select Range A1 again
Basically VBA code start with Sub (Open), macro name, some note(Start with hyphen(')), active code and End sub (Close).
Now you can start the editing. Good luck
Remember to follow the fire...