Introduction to Microsoft Excel and VBA
Using Microsoft Excel
Microsoft Excel is a spreadsheet application used to create lists, perform calculations, and analyze numbers. It can be used in business, economics, or accounting, etc.
While the default features of Microsoft Excel should be enough in most scenarios, in some cases you will want more complex functionality to perform advanced operations. To make this possible, Microsoft Excel is accompanied by Microsoft Visual Basic, a programming environment that allows you to use the Visual Basic language to enhance the usefulness and functionality of a spreadsheet.
To use Microsoft Excel, you can launch like any regular Microsoft Windows application. You can click Start -> (All) Programs -> Microsoft Office -> Microsoft Office Excel 2007. If you have a Microsoft Excel document in Windows Explorer, in My Documents, or in an email, etc, you can double-click it. This would also start Microsoft Excel and would open the document.
The classic way users launch Microsoft Excel is from the Start menu on the task bar. You can also start the application from a shortcut on the desktop. There are many ways you can create a shortcut on your desktop. To create a Microsoft Excel shortcut on the desktop, do one of the following:
When Microsoft Excel opens, it displays an interface divided in various sections. The top section displays the title bar which starts on the left side with the Office Button . If you position the mouse on it, a tool tip would appear:
When clicked, the Office Button displays a menu:
As you can see, the menu of the Office Button allows you to perform the routine Windows operations of a regular application, including creating a new document, opening an existing file, or saving a document, etc. If you right-click the office button, you would get a short menu:
We will come back to the options on this menu.
The Quick Access Toolbar is on the right side of the Office Button. It displays a few buttons. If you right-click the Quick Access toolbar, a menu would appear:
To hide the Quick Access toolbar, you can right-click it and click Remove Quick Access Toolbar. If you position the mouse on a button, a tool tip would appear.
In the beginning, the Quick Access toolbar displays only three buttons: Save, Undo, and Redo. If you want more buttons than that, you can right-click the Quick Access toolbar and click Customize Quick Access Toolbar... This would display the Excel Options dialog box:
To add a button to the Quick Access toolbar, on the left list of Add, click an option and click Add. After making the selections, click OK.
To remove a button from the Quick Access toolbar, right-click it on the Quick Access toolbar and click Remove From Quick Access Toolbar.
A button with a down-pointing arrow displays on the right side of the Quick Access toolbar. You can click or right-click that button to display its menu:
The role of this button is to manage some aspects of the top section of the Microsoft Excel interface, including deciding what buttons to display on the Quick Access toolbar. For example, instead of using the Customize Quick Access Toolbar menu item as we saw previously, you can click an option from that menu and its corresponding button would be added to the Quick Access toolbar. If the options on the menu are nor enough, you can click either Customize Quick Access Toolbar or More Commands... This would open the Excel Options dialog box.
The main or middle area of the top section displays the name of the application: Microsoft Excel. You can right-click the title bar to display a menu that is managed by the operating system.
On the right side of the title bar, there are three system buttons that allow you to minimize, maximize, restore, or close Microsoft Access.
Under the title bar, there is another bar with a Help button on the right side.
Under the title bar, Microsoft Excel displays the Ribbon:
By default, the Ribbon displays completely in the top section of Microsoft Excel under the title bar. One option is to show it the way the main menu appeared in previous versions of Microsoft Excel. To do this:
This would display the Ribbon like a main menu:
To show the whole Ribbon again:
By default, the Quick Access toolbar displays on the title bar and the Ribbon displays under it. If you want, you can switch their locations. To do that, right-click the Office Button, the Quick Access toolbar, or the Ribbon, and click Show Quick Access Toolbar Below the Ribbon:
To put them back to the default locations, right-click the Office Button, the Quick Access toolbar, or the Ribbon, and click Show Quick Access Toolbar Above the Ribbon.
The ribbon is a type of property sheet made of various property pages. Each page is represented with a tab. To access a tab:
To identify each tab of the Ribbon, we will refer to them by their names.
Each tab of the ribbon is divided in various sections, each delimited by visible borders of vertical lines on the left and right. Each section displays a title in its bottom side. In our lessons, we will refer to each section by that title. For example, if the title displays Font, we will call that section, "The Font Section".
Some sections of the Ribbon display a button . If you see such a button, you can click it. This would open a dialog box or a window.
Since there are various buttons and sometimes they are unpredictable, to know what a particular button is used for, you can position your mouse on it and a tool tip would appear:
You can also use context sensitive help in some cases to get information about an item.
You can add a button from a section of the Ribbon to the Quick Access toolbar. To do that, right-click the button on the Ribbon and click Add to Quick Access Toolbar:
Remember that, to remove a button from the Quick Access toolbar, you can right-click it on the Quick Access toolbar and click Remove From Quick Access Toolbar.
In some sections of the Ribbon, on the lower-right corner, there is a button:
That button is used to display an intermediary dialog box for some actions.
When Microsoft Excel is occupying a big area or the whole area of the monitor, most buttons of the Ribbon appear with text. Sometimes you may need to use only part of the screen. That is, you may need to narrow the Microsoft Excel interface. If you do, some of the buttons may display part of their appearance and some would display only an icon. Consider the difference in the following three screenshots:
In this case, when you need to access an object, you can still click it or click its arrow. If the item is supposed to have many objects, a new window may appear and display those objects:
Under the Ribbon, there is a white box displaying a name like A1 (it may not display A1...), that small box is called the Name Box:
On the right side of the Name box, there is a gray box with an fx button. That fx button is called the Insert Function button.
On the right side of the Insert Function button is a long empty white box or section called the Formula Bar:
You can hide or show the Formula Bar anytime. To do this, on the Ribbon, click View. In the Show/Hide section:
Under the Name Box and the Formula bar, you see the column headers. The columns are labeled A, B, C, etc:
There are 255 of columns.
On the left side of the main window, there are small boxes called row headers. Each row header is labeled with a number, starting at 1 on top, then 2, and so on:
The main area of Microsoft Excel is made of cells. A cell is the intersection of a column and a row:
A cell is identified by its name and every cell has a name. By default, Microsoft Excel appends the name of a row to the name of a column to identify a cell. Therefore, the top-left cell is named A1. You can check the name of the cell in the Name Box.
On the right side of the cells area, there is a vertical scroll bar that allows you to scroll up and down in case your document cannot display everything at a time:
In the lower right section of the main window, there is a horizontal scroll bar that allows you to scroll left and right if your worksheet has more items than can be displayed all at once:
Sometimes the horizontal scroll bar will appear too long or too narrow for you. If you want, you can narrow or enlarge it. To do this, click and drag the button on the left side of the horizontal scroll bar:
On the left side of the horizontal scrollbar, there are the worksheet tabs:
By default, Microsoft Excel provides three worksheets to start with. You can work with any of them and switch to another at any time by clicking its tab.
On the left side of the worksheet tabs, there are four navigation buttons:
If you happen to use a lot of worksheets or the worksheet names are using too much space, which would result in some worksheets being hidden under the horizontal scroll bar, you can use the navigation buttons to move from one worksheet to another.
Under the navigation buttons and the worksheet tabs, the Status Bar provides a lot of information about the job that is going on.
A Microsoft Excel file gets saved like any traditional Windows file. To save a file:
Two issues are important. Whenever you decide to save a file for the first time, you need to provide a file name and a location. The file name helps the computer identify that particular file and register it.
A file name can consist of up to 255 characters, you can include spaces and dashes in a name. Although there are many characters you can use in a name (such as exclamation points, etc), try to avoid fancy names. Give your file a name that is easily recognizable, a little explicit. For example such names as Time Sheets, Employee's Time Sheets, GlobalEX First Invoice are explicit enough. Like any file of the Microsoft Windows operating systems, a Microsoft Excel file has an extension, which is .xls but you don't have to type it in the name.
The second important piece of information you should pay attention to when saving your file is the location. The location is the drive and/or the folder where the file will be saved. By default, Microsoft Excel saves its files in the My Documents folder. You can change that in the Save As dialog box. Just click the arrow of the Save In combo box and select the folder you want.
Microsoft Excel allows you to save its files in a type of your choice. To save a file in another format:
There are other things you can do in the Save As dialog box:
You can save a file under a different name or in another location, this gives you the ability to work on a copy of the file while the original is intact.
There are two primary techniques you can use to get a file in two names or the same file in two locations. When the file is not being used by any application, in Windows Explorer (or in My Computer, or in My Network Places, locate the file, right-click it and choose Copy. To save the file in a different name, right-click in the same folder and choose Paste. The new file will be named Copy Of... You can keep that name or rename the new file with a different name (recommended). To save the file in a different location, right-click in the appropriate folder and click Paste; in this case, the file will keep its name.
In Microsoft Excel, you can use the Save As dialog box to save a file in a different name or save the file with the same name (or a different name) in another folder. The Save As dialog box also allows you to create a new folder while you are saving your file (you can even use this technique to create a folder from the application even if you are not saving it; all you have to do is create the folder, click OK to register the folder, and click Cancel on the Save As dialog box).
The files you use could be created by you or someone else. They could be residing on your computer, on another medium, or on a network. Once one of them is accessible, you can open it in your application.
You can open a document either by double-clicking its icon in Windows Explorer, in My Computer, from the Find Files Or Folders window, in My Network Places, or by locating it in the Open dialog box. To access the open dialog box, on the main menu, click File -> Open... You can also click the Open button on the Standard toolbar.
A shortcut to call the Open dialog box is Ctrl + O.
Every file has some characteristics, attributes, and features that make it unique; these are its properties. You can access a file's properties from three main areas on the computer:
A file's properties are used for various reasons. For example, you can find out how much size the file is using, where it is located (the hosting drive and/or folder), who created the file, or who was the last person to access or modify it. The Properties dialog box is also a good place to leave messages to other users of the same file, about anything, whether you work as a team or you simply want to make yourself and other people aware of a particular issue regarding the file.
Microsoft Excel is a spreadsheet application that provides simple to advanced means of creating and managing any type of list. To enhance it beyond its default function, it ships with a language called Microsoft Visual Basic or simply Visual Basic.
Microsoft Visual Basic for Applications (VBA) is a computer language based on Microsoft Visual Basic. It allows you to write code that can automatically perform actions on a document and/or its content. When using that language, you write pieces of code, using an external environment.
Microsoft Visual Basic is a programming environment that gets automatically installed when you setup Microsoft Excel. It stays apart because most people would not need or use it. This means that, if you want to use the Microsoft Visual Basic programming environment that ships with Microsoft Excel, you must ask for it, which can be easily done.
In our lessons, we will learn how to use both Microsoft Excel and Microsoft Visual Basic to create and manage spreadsheets. The Microsoft Visual Basic programming environment we will use depends on Microsoft Excel. As a result, to use Microsoft Visual Basic, you must first open Microsoft Excel. Then, to write code, you must open Microsoft Visual Basic. There are various ways you can do this, depending on your intention.
To launch Microsoft Visual Basic using the default installation of Microsoft Excel and launching from a macro, on the Ribbon, you can click View. In the Macros section, click the arrow under the Macros button and click Record a Macro:
This would display the Record Macro dialog box:
On the Record Macro dialog box, (do something or) simply click OK. Then, in the Macros section of the Ribbon, click the arrow under the Macros button and click Stop Recording. Now, to open Microsoft Visual Basic, in the Macros section of the Ribbon, click either the Macros button itself or click the arrow under it and click View Macros:
In the combo box, select the name of the macro you created (if you have only one, it should be selected already) and click Edit.
There is probably the best way for a programmer like you to launch Microsoft Visual Basic. Click the Office Button and click Excel Options. In the Excel Options dialog box, click the Show Developer tab in the Ribbon check box and click OK. The Ribbon would become equipped with a new tab:
From the Developer tab of the Ribbon, to launch Microsoft Visual Basic, click the Visual Basic button.
When it opens, like any regular Windows application, Microsoft Visual Basic displays a title bar in the top section. Under the title bar, the application displays a menu, followed by a Standard toolbar.
To assist you with your development, Microsoft Visual Basic can display various windows.
The Project Explorer window shows a list of the code segments that are available to your worksheet. It is usually available whenever you open Microsoft Visual Basic. It is usually positioned in the top-left section. If it is not present, to display it, on the main menu of Microsoft Visual Basic, you can click View -> Project Explorer. To close it, you can click its Close button .
You can move the Project Explorer to another section of the interface. To do this, click its title bar and drag it away it from there:
To put the window back where it was previously, you can double-click its title bar.
The Properties window is usually positioned in the bottom-left section of the screen. When it does not appear, to display it, on the main menu, click View -> Properties Window:
The Properties Window shows the characteristics of an object that is selected. Like any other window, to move the Properties window from its position, drag its title bar:
The main area of Microsoft Visual Basic uses a gray background. This area is gray because, in reality, Microsoft Visual Basic is a multiple document interface (MDI) that can be used to display various windows at the same time. At times, this gray area will be occupied with other windows.
A module is a blank window that resembles a piece of paper on which you write code. When you use Microsoft Excel and work on a document, a default module is automatically allocated for it, whether you use it or not. You can also create a module that is independent of any worksheet.
To create a module, on the main menu of Visual Basic, you can click Insert -> Module.
To help you test code, Microsoft Visual Basic provides a special window called the Immediate Window. To display it, on the main menu of Microsoft Visual Basic, you can click View -> Immediate Window.
|Home||Copyright © 2008-2009, yevol.com||Next|