Creating VBA in Microsoft Excel 2010

Adding an active x control in Microsoft Excel 2010 is not as obvious as in the earlier versions of MS Excel. The default worksheet in Microsoft Excel 2010 does not show the controls.

In order to bring up the controls, you need to make the developer tab visible. To display the developer tab, click File and then click Options. In the Options dialog, click Customize Ribbon and under Main Tabs check the Developer box, as shown in the Figure below:

showdeveloper

 

Now your Microsoft Excel workbooks shows the Developer tab and the ActiveX controls are available there, as shown in the Figure below:

showdeveloper_xcel

 

Formatting Font and Background Colors in Excel Spreadsheet

We can write Excel VBA code to format the color of a MS Excel spreadsheet. Using  Excel VBA code, we can change the font color as well as the the background color of each cell effortlessly.

Alright, let’s create a program that can format random font and background colors using a randomize process. Colors can be assigned using a number of methods in Excel VBA, but it is easier to use the RGB function. The RGB function has three numbers corresponding to the red, green and blue components. The range of values of the three numbers is from 0 to 255. A mixture of the three primary colors will produce different colors.

More details here:

http://excelvbatutor.com/index.php/excel-vba-lesson-12/

Creating Animation in Excel VBA

Though generally we create Excel VBA code for mathematical and financial calculations, it is also possible to creating some fun applications in Excel VBA, including games and animation. Although professionals programmers might not be interested to write such applications, it is worth while trying them out as a hobby and for personal satisfaction.

Visit this link to find out more:

http://excelvbatutor.com/index.php/excel-vba-lesson-22/

Formatting Functions in Excel VBA

Formatting output is a very important part of Excel VBA programming so that the data can be presented systematically and clearly to the users. Data in the previous lesson were presented fairly systematically through the use offunctions like Int, Fix and Round. However, to have better control of the output format, we can use a number of formatting functions in Excel VBA.

Read more about formatting functions at:

http://excelvbatutor.com/index.php/excel-vba-lesson-9/

Excel VBA Functions

In Excel VBA, a function is similar to a procedure but the main purpose of the function is to accept a certain input from the user and return a value which is passed on to the main program to finish the execution. There are two types of functions, the built-in functions (or internal functions) and the functions created by the programmers, or simply called user-defined functions. We shall deal with built-in functions in this lesson and the user-defined functions in the next lesson.

The first built-in function that we have already learned and familiar with its usage is the Message Box. We are not going to repeat here but we shall take a look at its syntax once more, i.e.

message=MsgBox(Prompt, Style Value,Title)

Now we shall examine the next commonly used function in Excel VBA, it is none other than the InputBox function.

Read more about functions at: http://excelvbatutor.com/index.php/excel-vba-lesson-8/

Excel VBA Lesson 1: Introduction to Excel VBA

[Contents] <<Lesson 2>>

1.1 What is Excel VBA?

Excel VBA is the acronym for Excel Visual Basic for Applications. It is an integration of the Microsoft’s event-driven programming language Visual Basic for Microsoft Office Applications such as Microsoft Excel. Using the Visual Basic programming language in Excel VBA, you can write customized solutions for the Microsoft Excel spreadsheet and complement its built-in functions. In addition, you can actually learn the fundamentals of Visual Basic programming without having to buy a copy of Visual Basic professional. Why is it so? It is because there is a built-in Visual Basic Editor in Microsoft Excel.


1.2  How to write Excel VBA Code?

There are two ways which you can write EXCEL VBA code. The first one is to place a command button on the spreadsheet and start writing codes by clicking the command button while the second one is to write Visual Basic codes within the Visual Basic Editor. Let’s start with the command button first. In order to place a command button on the spreadsheet, you need to click View on the MS Excel menu bar and then click on the toolbar and finally select the Control Toolbox to launch the control toolbox bar, as shown in Figure 1.1.

Excel VBA
Figure 1.1

The control toolbox comprises various controls. In this lesson, you only use the command button. Now click on the command button and draw it on the spreadsheet, as shown in Figure 1.2


Figure 1.2




Next,  click on the command button to bring up the Visual Basic Editor. In the Visual Basic Editor,  enter the statements as shown in Figure 1.2. The first statement fills up cell A1 to cell A10 with the phrase “Visual Basic” while the second statement adds the value in cell A11 and cell B11  and then shows the sum in cell C11. It is that simple.

Figure 1.2

Run the macro and you can see the output as shown in Figure 1.3  below:

Figure 1.3

[Contents] <<Lesson 2>>

Welcoming Message from the Webmaster

We have transferred the entire Excel VBA tutorial website to this new domain. The main objective is to provide a more user-friendly learning environment to learn Excel VBA macro programming. It is still in the building process, we hope that you can provide your useful feedbacks for us to build a better website. Thank you!

Excel VBA Tutorial

Excel VBA Tutorial provides step by step guide in learning VBA for the older versions of MS Excel such MS Excel 2003. We provide a separate VBA tutorial for the newer MS Excel 2010.  Start learning how to create VBA in Microsoft Excel by following the lessons below.

Table of Contents

Lesson 1: Introduction to Excel VBA
Lesson 2: Working with Variables
Lesson 3: Working with Arrays
Lesson 4:  Operators
Lesson 5: Sub Procedures and Functions
Lesson 6: Mathematical Functions
Lesson 7: Trigonometric Functions
Lesson 8: String Manipulating Functions
Lesson 9: Formatting Functions
Lesson 10: Financial Functions
Lesson 11: Date and Time Functions
Lesson 12:Using If Then Else
Lesson 13: Select Case
Lesson 14: Looping
Lesson 15: Do Loop
Lesson 16: Formatting Font and Background Color
Lesson 17: Introducing Excel VBA Object2 Part 1
Lesson 18: Introducing Excel VBA Objects Part 2
Lesson 19: The Range Object
Lesson 20: The worksheet Object
Lesson 21: The workbook Object
Lesson 22: Working with Check Box and Option Button
Lesson 23: Working with List Box, Combo Box and Toggle Button
Lesson 24: Creating Charts and Graphs in Excel VBA
Lesson 25: Creating Animation in Excel VBA



Excel VBA Tutorials

Excel VBA Tutorials provide many lessons written in an easy manner to help you master Excel VBA macro programming. Our tutorials cover both Excel VBA programming for the older version of Excel as well as the newer version Excel 2010. However, the syntaxes remain the same as that of Visual Basic 6 even for the latest versions of Excel.In addition, we also run tutorials on Visual Basic, JavaScript, JQuery and Blockchain.

Our tutor Dr.Liew has authored an e-book, Excel VBA Made Easy that can be used as a reference book for your excel VBA projects. The book is also available on your mobile devices and kindle.

Featured Excel VBA Book

by Dr.Liew

Preview the book

What is VBA ?

VBA is the acronym for Visual Basic for Applications.  It is similar to the  Microsoft programming language Visual Basic except that it is embedded within the MS Office applications such as MS Excel, MS Words, MS Access, MS Powerpoint and more.  VBA allows you to create customized programs using the built-in Visual Basic Editor in MS applications.  These programs are also known as macros.  The macros can greatly enhance the functionality of the Microsoft applications.



<br /> (adsbygoogle = window.adsbygoogle || []).push({});<br />