পৃষ্ঠাসমূহ

Search Your Article

CS

Pageviews

Showing posts with label VBA Tutorial. Show all posts
Showing posts with label VBA Tutorial. Show all posts

Thursday, February 9, 2017

VBA - Overview

VBA stands for Visual Basic for Applications an event-driven programming language from Microsoft that is now predominantly used with Microsoft office applications such as MSExcel, MS-Word, and MS-Access.
It helps techies to build customized applications and solutions to enhance the capabilities of those applications.

VBA - Excel Macros

In this chapter, you will learn how to write a simple macro in a step by step manner.
Step 1 − First, enable 'Developer' menu in Excel 20XX. To do the same, click File → Options.
Step 2 − Click ‘Customize the Ribbon’ tab and check 'Developer'. Click 'OK'.

VBA - Excel Terms

In this chapter, you will acquaint yourself with the commonly used excel VBA terminologies. These terminologies will be used in further modules, hence understanding each one of these is important.

VBA - Macro Comments

Comments are used to document the program logic and the user information with which other programmers can seamlessly work on the same code in future.

VBA - Message Box

The MsgBox function displays a message box and waits for the user to click a button and then an action is performed based on the button clicked by the user.

VBA - InputBox

The InputBox function prompts the users to enter values. After entering the values, if the user clicks the OK button or presses ENTER on the keyboard, the InputBox function will return the text in the text box. If the user clicks the Cancel button, the function will return an empty string ("").

VBA - Variables

Variable is a named memory location used to hold a value that can be changed during the script execution. Following are the basic rules for naming a variable.

VBA - Constants

Constant is a named memory location used to hold a value that CANNOT be changed during the script execution. If a user tries to change a Constant value, the script execution ends up with an error. Constants are declared the same way the variables are declared.

VBA - Operators

An Operator can be defined using a simple expression - 4 + 5 is equal to 9. Here, 4 and 5 are called operands and + is called operator. VBA supports following types of operators −

VBA - Decisions

Decision making allows the programmers to control the execution flow of a script or one of its sections. The execution is governed by one or more conditional statements.
Following is the general form of a typical decision making structure found in most of the programming languages.

VBA - Loops

There may be a situation when you need to execute a block of code several number of times. In general, statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on.

VBA - Strings

Strings are a sequence of characters, which can consist of either alphabets, numbers, special characters, or all of them. A variable is said to be a string if it is enclosed within double quotes " ".

VBA - Date-Time Function

VBScript Date and Time Functions help the developers to convert date and time from one format to another or to express the date or time value in the format that suits a specific condition.

VBA - Arrays

We know very well that a variable is a container to store a value. Sometimes, developers are in a position to hold more than one value in a single variable at a time. When a series of values are stored in a single variable, then it is known as an array variable.

VBA - User Defined Functions

A function is a group of reusable code which can be called anywhere in your program. This eliminates the need of writing the same code over and over again. This enables the programmers to divide a big program into a number of small and manageable functions.

VBA - Sub Procedure

Sub Procedures are similar to functions, however there are a few differences.
  • Sub procedures DO NOT Return a value while functions may or may not return a value.
  • Sub procedures CAN be called without a call keyword.
  • Sub procedures are always enclosed within Sub and End Sub statements.

VBA - Events

VBA, an event-driven programming can be triggered when you change a cell or range of cell values manually. Change event may make things easier, but you can very quickly end a page full of formatting. There are two kinds of events.

VBA - Error Handling

There are three types of errors in programming: (a) Syntax Errors, (b) Runtime Errors, and (c) Logical Errors.

Syntax errors

Syntax errors, also called as parsing errors, occur at the interpretation time for VBScript. For example, the following line causes a syntax error because it is missing a closing parenthesis.

VBA - Excel Objects

When programming using VBA, there are few important objects that a user would be dealing with.
  • Application Objects
  • Workbook Objects
  • Worksheet Objects
  • Range Objects

VBA - Text Files

You can also read Excel File and write the contents of the cell into a Text File using VBA. VBA allows the users to work with text files using two methods −
  • File System Object
  • using Write Command