文档详情

EXCEL Visual Basic Tutorial Problems (Version (EXCEL Visual Basic教程的问题(版本).pdf

发布:2017-07-28约3.34万字共17页下载文档
文本预览下载声明
Visual basic tutorial problems, developed by Dr. Clement, clement@ EXCEL Visual Basic Tutorial Problems (Version January, 2011) Dr. Prabhakar Clement Arthur H. Feagin Distinguished Chair Professor Department of Civil Engineering, Auburn University Home page: /users/clemept/ Email: clement@ How to activate the Developer Tab? When you open EXCEL (in Office 2007) you should see a tab called “Developer” in the very end next to the “View” tab. If you don’t then you need to activate it. You can do this by clicking on the office menu button (round button in left, where you have the print, save commands). At the very bottom of this menu you will see Excel options (see the figure below), click on that and then select (check mark) “Show Developer tab in the ribbon.” Say ok. Now you should see the Developer tab. 1 Visual basic tutorial problems, developed by Dr. Clement, clement@ Note: Textbooks often follow different approaches for writing a VB code. The method shown here is a relatively simple and straight forward approach to write a VB code in EXCEL. The problem below shows how to create a VB button and rename it to name you like. But you don’t have to rename, you can just leave it as the default name of “Sub CommandButton1_Click()” the program should still work. Test Problem-0: Develop a simple calculator that will add or subtract numbers two numbers entered in a spreadsheet. The final result will look like this: The VB code for the ADD and SUBTRACT buttons are: Option Explicit Option Base 1 Private Sub codeAdd_Click() Dim a As Single, b As Single, c As Single a = Cells(1, 2) b = Cells(3, 2) c = a + b Cells(5, 2) = c End Sub Private Sub codeSubtract_Click() Dim a As Single, b As Single, c As Single a = Cells(1, 2) 2 Visu
显示全部
相似文档