Download presentation
Presentation is loading. Please wait.
Published byBlanche Ferguson Modified over 9 years ago
1
VBA: A BRIEF INTRODUCTION SEAMUS STEGENGA MEEN 381-506 FEBRUARY 11, 2015
2
OVERVIEW Introduction…………… 1 slide History………………… 2 slides Hypothetical example… 10 slides Real-world example…… 2 slides Pros and cons ………… 1 slide Conclusion …………… 1 slide Questions……………… 1 slide
3
INTRODUCTION VBA is a proprietary object-oriented programming language developed by Microsoft It is built in to MS office installations (Anyone with Excel already has it installed on their computer) It allows users to automate tasks, manipulate large data sets, and create custom interfaces
4
HISTORY Early computing had many programming languages Problem: steep learning curve In 1975, Bill Gates dropped out of Harvard to create an interpreter for BASIC Product was instant success, becoming the central product of his company, Microsoft Independently, VisiCal, the first spreadsheet program, was created in 1978 It was also an instant success, becoming the first “killer app” and substantially boosting PC sales Lotus 1-2-3 soon followed, becoming the dominate entry in the spreadsheet market Microsoft tried to compete with Microplan (predecessor to Excel), but generally failed to gain market share
5
HISTORY 15 years later, Microsoft was still struggling to gain market share Then, in 1993, Microsoft combined its BASIC interpreter with Excel The result was VBA, an object-oriented language centered around the MS office suite VBA-based Excel was successful beyond even Microsoft’s expectations, Lotus 1-2-3 lost dominate market position in 1995 and was bought by IBM later that year Since then, Excel has become a de-facto standard in business settings (especially engineering)
6
EXAMPLE: PROBLEM STATEMENT Suppose that on a particular project, your boss tells you to check which AutoCAD drawings have been updated and need to be re-sent to the client. They give you a list of drawings, the current revision of each drawing, and a list of filenames that have already been sent. Which drawings need to be resent? DRAWINGREVFILENAME AG10-4637-GAE1.2AG10-4637-GAE rev 1.2.DWG AG11-5620-GAE1AG11-5620-GAErev1.0.dwg AG12-4004-GAE1.2AG12-4004-GAErev1.2.dwg AG14-9294-GAE1.1AG14-9294-GAE_1.1.DWG AG15-1937-GAE1.2AG15-1937-GAErev1.1.dwg AG15-3441-GAE1.2AG15-3441-GAE Rev1.2.dwg AG16-7964-GAE1AG16-7964-GAE Rev1 AG17-7538-GAE1.1AG17-7538-GAE Rev1.1.dwg AG20-1013-GAE1AG20-1013-GAE_1.0.DWG AG22-6293-GAE1AG22-6293-GAE_1.0.DWG AG22-6939-GAE1.1AG22-6939-GAE Rev1.1.dwg AG23-9721-GAE2AG23-9721-GAE Rev1.2 AG26-1252-GAE1AG26-1252-GAE_1.DWG AG26-3982-GAE2AG26-3982-GAE rev 2.dwg AG26-7808-GAE1AG26-7808-GAE rev1.0.dwg AG28-4049-GAE1AG28-4049-GAE_1 AG30-4827-GAE1AG30-4827-GAErev1.0.DWG AG31-9504-GAE1AG31-9504-GAErev1.0.DWG AG34-6161-GAE1.2AG34-6161-GAE rev 1.2 AG37-2632-GAE1AG37-2632-GAE rev 1.0.DWG AG37-4679-GAE1AG37-4679-GAErev1 AG37-4922-GAE1.1AG37-4922-GAE Rev1.1.dwg AG39-4773-GAE1AG39-4773-GAE rev1 AG42-1418-GAE1.2AG42-1418-GAE Rev1.2.dwg AG44-6605-GAE2AG44-6605-GAErev2.dwg
7
EXAMPLE: PROBLEM STATEMENT Suppose that on a particular project, your boss tells you to check which AutoCAD drawings have been updated and need to be re-sent to the client. They give you a list of drawings, the current revision of each drawing, and a list of filenames that have already been sent. Which drawings need to be resent? DRAWINGREVFILENAME AG10-4637-GAE1.2AG10-4637-GAE rev 1.2.DWG AG11-5620-GAE1AG11-5620-GAErev1.0.dwg AG12-4004-GAE1.2AG12-4004-GAErev1.2.dwg AG14-9294-GAE1.1AG14-9294-GAE_1.1.DWG AG15-1937-GAE1.2AG15-1937-GAErev1.1.dwg AG15-3441-GAE1.2AG15-3441-GAE Rev1.2.dwg AG16-7964-GAE1AG16-7964-GAE Rev1 AG17-7538-GAE1.1AG17-7538-GAE Rev1.1.dwg AG20-1013-GAE1AG20-1013-GAE_1.0.DWG AG22-6293-GAE1AG22-6293-GAE_1.0.DWG AG22-6939-GAE1.1AG22-6939-GAE Rev1.1.dwg AG23-9721-GAE2AG23-9721-GAE Rev1.2 AG26-1252-GAE1AG26-1252-GAE_1.DWG AG26-3982-GAE2AG26-3982-GAE rev 2.dwg AG26-7808-GAE1AG26-7808-GAE rev1.0.dwg AG28-4049-GAE1AG28-4049-GAE_1 AG30-4827-GAE1AG30-4827-GAErev1.0.DWG AG31-9504-GAE1AG31-9504-GAErev1.0.DWG AG34-6161-GAE1.2AG34-6161-GAE rev 1.2 AG37-2632-GAE1AG37-2632-GAE rev 1.0.DWG AG37-4679-GAE1AG37-4679-GAErev1 AG37-4922-GAE1.1AG37-4922-GAE Rev1.1.dwg AG39-4773-GAE1AG39-4773-GAE rev1 AG42-1418-GAE1.2AG42-1418-GAE Rev1.2.dwg AG44-6605-GAE2AG44-6605-GAErev2.dwg
8
EXAMPLE: SOLUTION Pressing Alt+F11 pulls up the VBA editor
9
EXAMPLE: SOLUTION Double clicking “ThisWorkbook” brings up a white text editor
10
EXAMPLE: SOLUTION Typing “Sub example_name” and pressing enter creates a new sub-routine Code is automatically color-coded as you type
11
EXAMPLE: SOLUTION Write your macro cells(2,3).value => value of cell C2 UCase(“string”) => “STRING” Right(“string”,4) => “ring” CDec(“1.49”) => 1.49 Replace(“i pie”,”i”,”U”) => “U pUe” Typing the function name and open parenthesis will make a tooltip pop up, telling you what inputs the function is expecting. This is very useful! Most functions can be found using online search
12
EXAMPLE: SOLUTION Clicking the green triangle on the top window executes the macro (can also start by pressing F5) Afterwards, the Excel pane looks like the following DRAWINGREVFILENAMES AG10-4637-GAE1.2AG10-4637-GAE rev 1.2.DWG AG11-5620-GAE1AG11-5620-GAErev1.0.dwg AG12-4004-GAE1.2AG12-4004-GAErev1.2.dwg AG14-9294-GAE1.1AG14-9294-GAE_1.1.DWG AG15-1937-GAE1.2different!AG15-1937-GAErev1.1.dwg AG15-3441-GAE1.2AG15-3441-GAE Rev1.2.dwg AG16-7964-GAE1AG16-7964-GAE Rev1 AG17-7538-GAE1.1AG17-7538-GAE Rev1.1.dwg AG20-1013-GAE1AG20-1013-GAE_1.0.DWG AG22-6293-GAE1AG22-6293-GAE_1.0.DWG AG22-6939-GAE1.1AG22-6939-GAE Rev1.1.dwg AG23-9721-GAE2different!AG23-9721-GAE Rev1.2 AG26-1252-GAE1AG26-1252-GAE_1.DWG AG26-3982-GAE2AG26-3982-GAE rev 2.dwg AG26-7808-GAE1AG26-7808-GAE rev1.0.dwg AG28-4049-GAE1AG28-4049-GAE_1 AG30-4827-GAE1AG30-4827-GAErev1.0.DWG AG31-9504-GAE1AG31-9504-GAErev1.0.DWG AG34-6161-GAE1.2AG34-6161-GAE rev 1.2 AG37-2632-GAE1AG37-2632-GAE rev 1.0.DWG AG37-4679-GAE1AG37-4679-GAErev1 AG37-4922-GAE1.1AG37-4922-GAE Rev1.1.dwg AG39-4773-GAE1AG39-4773-GAE rev1 AG42-1418-GAE1.2AG42-1418-GAE Rev1.2.dwg AG44-6605-GAE2AG44-6605-GAErev2.dwg
13
EXAMPLE: ADDING FEATURES If desired, you can also make Excel relay information using a variety of pop-ups For example, 9 lines were added to the previous code, as shown on right
14
EXAMPLE: ADDING FEATURES If desired, you can also make Excel relay information using a variety of pop-ups For example, 9 lines were added to the previous code, as shown on right The result is a text pop-up listing the out- of-date drawings This can be copied directly into Outlook!
15
EXAMPLE: FINAL WORD VBA is helpful with: Large data sets Repetitive tasks Interacting with other programs Removing sheet protection Hiding formulas Dynamic links to external files
16
REAL-WORLD EXAMPLE Real-world example: BOM => requisition forms
17
REAL-WORLD EXAMPLE Without VBA: Sort by manufacturer Copy data, paste without formatting Each copy-paste repeated ~15 times per BOM Error prone With VBA: Single button added to ribbon A single click creates and saves one requisition form per vendor Fast and low error rate Furthermore, errors are not the kinds that “slip through the cracks” 4 hour process => 5 minute process!
18
AUTOMATING EXCEL: PROS AND CONS PROS Completes complex tasks quickly Allows for greater control over Excel Reduces errors CONS Large initial time investment Typically not flexible Encourages overreliance on technology
19
CONCLUSION VBA is an important part of Microsoft’s history can speed up repetitive tasks and add features to Excel is easy to learn and has a helpful online community requires a large initial time investment but can save hundreds of man-hours!
20
REFERENCES "Is Visual Basic That Basic?" What Is Visual Basic? Software Engineer Insider, Nov. 2012. Web. 11 Feb. 2015. Martin, Kipp. "Introduction to VBA." University of Chicago: Booth School of Business (2012): n. pag. 4 Jan. 2012. Web. 11 Feb. 2015. Power, D. J. "A Brief History of Spreadsheets." DSSResources.com, 30 Aug. 2004. Web. 11 Feb. 2015.
21
QUESTIONS ?
22
?
23
?
24
?
25
?
26
?
27
?
28
?
29
?
30
?
31
?
32
?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.