Getting Started With Visual Basic In Excel

3y ago
34 Views
2 Downloads
1.15 MB
15 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Mariam Herr
Transcription

TIM-125/225: MOT II Supply Chain ManagementGetting Started with Visual Basic in ExcelPrepared by: Rany Polany (2012) & Daniel Core (2009)UCSC, Baskin School of EngineeringTable of ContentsVisual Basic Related Questions . 1123456Where can I find useful Visual Basic tutorials? . 1How do I open the Visual Basic Editor in Excel? . 1How to I program in the Visual Basic Editor . 1How do I reference a cell in a workbook? . 2How do I link a cell between two different Worksheets? . 2How do I use Solver to perform an optimization? . 3Examples of Software from Previous Years . 41.2.3.4.5.6.7.Example: Simple High-level GUI Showing Modules Available to the User . 4Example: Intermediate Demand Forecasting GUI Showing Inputs By the User . 5Example: Output: Demand Forecasting . 6Example: Alternative Output for Demand Forecasting . 7Example: Advanced Main Level GUI . 8Example: Advanced Data Entry Input for User . 11Example: Advanced Chart Output . 12Additional Web References:. 13

TIM-125/225: MOT II Supply Chain ManagementGetting Started with Visual Basic in ExcelVisual Basic Related Questions1 Where can I find useful Visual Basic tutorials?The tutorial below provide an elementary entry point, complete with pictures to the world ofVisual Basic. They demonstrate how macros are made of Subs, which are subroutines in theprogram. If you are familiar with Java or C, this is similar to a Method.Tutorial 1: Excel VBA Basic Tutorial mA very basic introduction that provides a good overview to using Visual Basic in Excel.Tutorial 2: Programming In Excel VBA - An rogrammingInExcelVBA AnIntroduction.pdfAnother Introduction to VBA programming.2How do I open the Visual Basic Editor in Excel?To start using Visual Basic open the Menu: Tools (Excel 2007) or Developer Tab (Excel 2010) Macro Visual Basic Editor.If the Developer Tab is not visible in the ribbon, follow the instructions 625.aspxFigure 1: Excel 2007 Tools MenuFigure 2: Excel 2011 Developer TabPage 1

TIM-125/225: MOT II Supply Chain ManagementGetting Started with Visual Basic in ExcelOnce you open the Visual Basic Editor, shown in Figure 3, on the left is the Project Browser.This has the different components of the program.Figure 3: Microsoft Visual Basic for Application programming environmentTo add a macro, double click on the sheet or workbook you wish to modify within the projectbrowser window and a new module will open on the right side to enter your program code.3 How to I program in the Visual Basic EditorType the following into the module as an example for the “Hello World”:Sub showMessage()MsgBox "Hello World"End SubFigure 4: Example of how to program "Hello World" ExampleTo run this program go to the Run menu on the top menu bar and click on the RunSub/UserForm (or you can click F5 on the keyboard).Page 1

TIM-125/225: MOT II Supply Chain ManagementGetting Started with Visual Basic in ExcelFigure 5: Running a Sub/UserFormThe program will display the phrase “Hello World” in a dialog box that pops up.Figure 6: Hello World run from the macro programSee Tutorial 1 for more detail.4 How do I reference a cell in a workbook?To reference a cell the Range command is used. See Tutorial 1: Section 2 for more details.5 How do I link a cell between two different Worksheets?This is a good Youtube.com video to demonstrate this process:Title: Linking Cells in Separate Worksheets in ExcelUploaded by ExcelisHell on Aug 18, 2008Website address: http://www.youtube.com/watch?v pIleRzwQ FU&feature relmfuThe author shows you how to link between two worksheets in one excel workbook to share data.Page 2

TIM-125/225: MOT II Supply Chain ManagementGetting Started with Visual Basic in Excel6 How do I use Solver to perform an optimization?For help programming Solver, please reference the built-in Help button,, within Excelusually located in the Top Right-Hand corner of the Excel Window. You can then search forkeyword: solver. A hyperlinked article will appear which provides a good starting point.Figure 7: Excel Help for using SolverYou can watch this free youtube.com video tutorial:Title: Using Excel Solver in Excel 2007Uploaded by niftynei on Mar 7, 2010Website address: http://www.youtube.com/watch?v YAugMpW-aJwThe author shows you how to install and use Solver Add-In for Excel 2007 on PC/Windows.Page 3

TIM-125/225: MOT II Supply Chain ManagementGetting Started with Visual Basic in ExcelExamples of Software from Previous YearsHere are sample screenshots from SCM software that was created in previous years.1. Example: Simple High-level GUI Showing Modules Available to the UserPage 4

TIM-125/225: MOT II Supply Chain ManagementGetting Started with Visual Basic in Excel2. Example: Intermediate Demand Forecasting GUI Showing Inputs By theUserFigure 8: Intermediate Demand Forecasting GUIButtons are created on a Form to allow the user to select the different forecasting method.Figure 9: Intermediate Simple Exponential Smoothing GUIA form is created to allow the user to enter the numeric values for the number of periods and thesmoothing constants for Alpha.Page 5

TIM-125/225: MOT II Supply Chain ManagementGetting Started with Visual Basic in Excel3. Example: Output: Demand ForecastingFigure 10: Simple Demand Forecasting Spreadsheet formattingSimple, but clean, formatting for the Demand Forecasting output of the data.Page 6

TIM-125/225: MOT II Supply Chain ManagementGetting Started with Visual Basic in Excel4. Example: Alternative Output for Demand ForecastingFigure 11: Alternative Output for Demand ForecastingCell formatting, colors, buttons, and auto-generated graphs.However, can you spot what is right, and wrong, with the Quarterly Demand graph plots shownabove?Page 7

TIM-125/225: MOT II Supply Chain ManagementGetting Started with Visual Basic in Excel5. Example: Advanced Main Level GUIFigure 12: Advanced Main Level GUI ExampleExample of a integerated main GUI control panel for Demand Forecasting, and the InventoryManagement, Facilities Management, and the Transportation management.Page 8

TIM-125/225: MOT II Supply Chain ManagementGetting Started with Visual Basic in ExcelBUTTON [1]: Upon Button click, the screen auto fits to the current maximize screen size.BUTTON [2]: Upon Button Click, this button will print the entire Current Worksheet containing the results of theSTEP 1, 2, 3 and 4.BUTTON [3]: Upon Button click, a screen will open to allow the user to enter 24 months of Monthly Demand Dataand the parameters of the Forecasting coefficients.BUTTON [4]: Upon Button Click, the software will perform calculations based on the program code written. Theresults will be displayed in the Summary Results to the right with the Best Model determined by the Month 24MAPE. The resulting demand will be displayed for the best model presented.BUTTON [5]: Upon Button Click, this group of buttons will open and display the actual Excel Worksheets for eachof the: Static. Each open sheet will also have an option to the return back to the MAIN or PRINT the selected sheet.BUTTON [6]: Upon Button Click, this group of buttons will open and display the actual Excel Worksheets for eachof: Moving Average. Each open sheet will also have an option to the return back to the MAIN or PRINT.BUTTON [7]: Upon Button Click, this group of buttons will open and display the actual Excel Worksheets for eachof the: Exponential. Each open sheet will also have an option to the return back to the MAIN or PRINT.BUTTON [8]: Upon Button Click, this group of buttons will open and display the actual Excel Worksheets for eachof the: Holt. Each open sheet will also have an option to the return back to the MAIN or PRINT.BUTTON [9]: Upon Button Click, this group of buttons will open and display the actual Excel Worksheets for eachof: Winter’s. Each open sheet will also have an option to the return back to the MAIN or PRINT.BUTTON [10]: Upon Button Click, this button will open the MS Excel worksheet that displays a completesummary of all the Forecasting techniques in one a page summary. On this opened sheet are available the option tothe return back to the MAIN or PRINT.BUTTON [11]: Upon Button Click, this button will open the MS Excel worksheet that displays a completesummary of all the Forecasting techniques in one a page summary.BUTTON [12]: Upon Button Click, this button will open the MS Excel worksheet that has been determined to bethe Optimal (Best) based on the lowest MAPE comparison.BUTTON [13]: Upon Button Click, this button will clear the current data in the Demand Summary ResultsBUTTON [14]: This is a ListBox selector. Upon Click on each list item, the Model Selected will be updated in theSummary Results: Model Selected cell. Though the Best Model has been calculated (STEP 1), this feature gives theuser the ability to choose different Forecasting methods and experiment with the Inventory Management results.BUTTON [19]: This is a data entry cell for whole numbers. The data entry should be for the Standard Deviation ofthe Weekly Demand. It is used to calculate the Safety Stock Inventory. Hit enter after typing in the value.BUTTON [15]: This is a data entry cell for whole numbers in percentage format. The data entry should be theHolding Cost in terms of a percentage value. Hit enter after typing in the value.BUTTON [16]: This is a data entry cell for the Per Unit Cost in dollars. Enter a dollar value. Hit enter after typing inthe value.BUTTON [17]: This is a data entry cell for the Common Order Cost ( ) for each order. Enter a dollar value. Hitenter after typing in the value.BUTTON [18]: This is a data entry cell for the CSL (%). Enter a percentage to represented the service level needed.Hit enter after typing in the value.BUTTON [19]: This is a data entry cell for the Lead Time (weeks) Enter a whole number value. Hit enter aftertyping in the value.Page 9

TIM-125/225: MOT II Supply Chain ManagementGetting Started with Visual Basic in ExcelBUTTON [20]: Upon Button Click, this button will compute all the variables based on the selected Forecastingmethod for the Inventory Management and display the results in the Summary table. To change the results, change avariable or choose a different an alternative forecasting method and click on Compute Inventory again.BUTTON [21]: Upon Button Click, this button will clear the entire of Inventory Summary resultsBUTTON [22]: Upon Button Click, this button will navigate to another worksheet to enter all the data andparameters needed for the Facilities Design computations.BUTTON [23]: Upon Button Click, this button will automate the computation of Facilities design utilizing SolverProgram for the optimization and will update the screen draw of the network.BUTTON [24]: Upon Button Click, will open the with automatically generate a Network Design figure.BUTTON [25]: Upon Button Click, this button will open the worksheet with the data results for the entireoptimization of the Facilities design.BUTTON [26]: Upon Button Click, will launch Risk Solver Platform for Monte Carlo Simulation analysisBUTTON [27]: Upon Button Click, this button will clear the entire of Facilities Summary resultsBUTTON [28]: Upon Button Click, this button will compute optimal Transportation results.BUTTON [29]: Upon Button Click, open the Transportation managementBUTTON [30]: Upon Button Click, this button will clear the Transportation Management results.Page 10

TIM-125/225: MOT II Supply Chain ManagementGetting Started with Visual Basic in Excel6. Example: Advanced Data Entry Input for UserDEMAND ENTRY FORM AND PARAMETERS 102842average5142.1min13197max1837HOLTS COEFFICIENTSalpha0.10beta0.10WINTERS COEFFICIENTSalpha0.10beta0.10gamma0.10MA Forecast Chart1010Exponential Forecast 0Period (t)20030Actual DemandForecasted (Holt's Method) 60004000800060004000200051015Period (Qtrs)202530Forecasted Demand (W inters Method)100008000600040002000030Demand: Winter's Method5 Year Plot with 2 Year ForecastDemand: Holt's Method5 Year Plot with 2 Year ForecastActual DemandForecasted (Exponential) Demand20Period (Qtrs)14000010Period (Qtrs)Demand: Exponential Smoothing5 Year Plot with 2 Year ForecastActual Demand800020000Demand Comparison SummaryINSTRUCTIONS:1. Enter Monthly Demand (units)2. Enter Coefficients for Adaptive Models (between 0 and 1)3. Once complete, click Main button to return to Main window6000200020.00101010 Winter's Forecast Graph800010000400040.00Holt's Forecast Graph1200014000120.00Forecasted (Moving Average) Deman d1400016000140.0010 Static Forecast ChartActual DemandDemand (Qty)0.10Demand: Moving Average5 Year Plot with 2 Year ForecastForecasted (Static) Demand18000160.00EXPONENTIAL COFFIECIENTSalphaActual DemandDemand 35355911234567891011121314151617181920Demand: Static Forecast5 Year Plot with 2 Year ForecastWintersDemand (Qty)3DemandD1ExponentialDemand (Qty)2StaticMoving AverageMAPE(t)1Plot of the MAPEt (5-Year)HoltsDemand (Qty)YearPeriod(Quarter)Clear Data Clear Data200000051015Period (Qtrs)202530051015Period (Qtrs)202530Figure 13: Advanced Data Entry Input ExampleIn the example, shown in Figure 13, you can see that the smoothing coefficients are adjustable using the scroll bar Form control.Additionally, the miniaturized charts for each forecasting method are presented in a Dashboard Cockpit on the right side for immediatevisual inspection upon adjustment of the Data or the smoothing coefficient. By presenting the Dashboard cockpit of the linked Charts, ithelps to ensure the smoothing coefficients are optimal. Buttons are also added that link the worksheet to other worksheets for moreexpedient maneuvering between the worksheets and full-page charts.Page 11

TIM-125/225: MOT II Supply Chain ManagementGetting Started with Visual Basic in Excel7. Example: Advanced Chart OutputFigure 14: Example of the Full-Page Static Forecasting ChartIn Figure 14 is shown an example of a Full-Page Chart for the Static Forecasting result. Noticethat the horizontal and vertical axes are both labeled. The data series are plotted with differenttypes of markers (squares vs dots), the legend is clearly labeled to which plot is Actual vsForecasted, the Chart Title is descriptive and in the top left and right hands sides, are buttons thatprovide direct links to the rest of the workbook. Additionally, an on-screen PRINT button isprovided, as well as a Save Chart (as picture) is provided.To export this Chart into Microsoft Word, you can follow this procedure:1. Click on the Outer Edge of the Chart, so that the entire Chart is selected.2. Select COPY3. Open MS Word.4. Then Paste Special. Select Bitmap or JPEG or PNG as the past option.There are more options for bringing the Chart into MS Word (and Powerpoint), but this providesa basic approach that prints well and easy to use. You can search online for more advancedgraphic editing approaches between Excel and Word (and Powerpoint). If you just copy andpaste from Excel to Word, you will not allows get clean formatting. Therefore, try to select aPicture type of format (e.g., Bitmap, JPEG, PNG)Also, remember to Label the Figure (i.e., Figure #: Title) and then explain this Figure.Page 12

TIM-125/225: MOT II Supply Chain ManagementGetting Started with Visual Basic in ExcelAdditional Web ch?v rtech.com/Excel/SolverVBA.htmlPage 13

Getting Started with Visual Basic in Excel Page 1 Once you open the Visual Basic Editor, shown in Figure 3, on the left is the Project Browser. This has the different components of the program. Figure 3: Microsoft Visual Basic for Application programming environment

Related Documents:

Visual Basic - Chapter 2 Mohammad Shokoohi * Adopted from An Introduction to Programming Using Visual Basic 2010, Schneider. 2 Chapter 2 –Visual Basic, Controls, and Events 2.1 An Introduction to Visual Basic 2.2 Visual Basic Controls 2.3 Visual Basic Events. 3 2.1 An Introduction to

Visual Basic 6.0 versus Other Versions of Visual Basic The original Visual Basic for DOS and Visual Basic F or Windows were introduced in 1991. Visual Basic 3.0 (a vast improvement over previous versions) was released in 1993. Visual Basic 4.0 released in late 1995 (added 32 bit application support).

Visual Basic is a third-generation event-driven programming language first released by Microsoft in 1991. The versions of visual basic in shown below: The final version of the classic Visual Basic was Visual Basic 6. Visual Basic 6 is a user-friendly programming language designed for beginners. In 2002, Microsoft released Visual Basic.NET (VB .

Biacore T200 Getting Started 28-9840-98 Edition AB 5 Biacore T200 Getting Started Biacore T200 Getting Started Introduction This Getting Started handbook is designed as a self-study guide to introduce you to the basic operations of BiacoreTM T200, Biacore T200 Control Software and Biacore T200 Evaluation Software.

What Visual Basic is not H Visual Basic is not, a powerful programming language that enables you to do anything you want. H Visual Basic is not, elegant or fast. H Visual Basic is not, a replacement for C. H Visual Basic is not, anything like any other programming language you have ever used.

Visual Basic 8.0 o Visual Basic 2005, nato nel 2005, è stato implementato sul .NET Framework 2.0. Non si usa più la keyword .NET nel nome, in quanto da questo momento sarà sottointeso che Visual Basic è basato sul .NET Framework. Visual Basic 9.0 o Visual Basic 2008, nato nel 2008, è stato implementato sul .NET Framework 3.5.

Bab 1 Pengenalan Visual Basic 6 Visual Basic 6 merupakan salah satu tool untuk pengembangan aplikasi yang banyak diminati oleh orang. Di sini Visual Basic 6 menawarkan kemudahan dalam pembuatan aplikasi dan dapat menggunakan komponen-komponen yang telah disediakan. Untuk memulai Visual Basic 6 anda perlu menginstall Visual Basic 6.0.

The Adventures of Tom Sawyer 4 of 353 She went to the open door and stood in it and looked out among the tomato vines and ‘jimpson’ weeds that constituted the garden. No Tom. So she lifted up her voice at an angle calculated for distance and shouted: ‘Y-o-u-u TOM!’ There was a slight noise behind her and she turned just