1 / 13

Excel Workshop Part II

Excel Workshop Part II. André Johnson UBC Okanagan IEEE Student Branch March 16, 2011. Outline:. VBA and Excel VBA Basics Recording a Macro Writing Basic Marcos User Prompts Importing Data Questions. VBA and Excel.

xandy
Download Presentation

Excel Workshop Part II

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Excel Workshop Part II André Johnson UBC Okanagan IEEE Student Branch March 16, 2011

  2. Outline: • VBA and Excel • VBA Basics • Recording a Macro • Writing Basic Marcos • User Prompts • Importing Data • Questions

  3. VBA and Excel • Visual Basic for Applications (VBA) is an implementation of  Microsoft’s Visual Basic 6 • Object Orientated • Supports Subroutine and Functions • Supports most common • VBA in Excel • Allows access to excel function in a programming language

  4. VBA Basics • Types of Variable • Declaring Variable • Pointers • Flow Control

  5. Types of Variables • Common Types • Variant (default), Byte, Boolean, Integer, Long, Single, Double, Date, String • Advanced Types • Object, Currency , Decimal, Date • User Defined • Excel Specific • Worksheet • Workbook

  6. Declaring a Variable • Dim – declare and dimension the variable • All variables are arrays • Private, Public, ReDim, or Static • Explicit option – define variables before using them in separate statement • Examples: • dim st_name As String • dim d_distance As Doube

  7. Pointers • Can be used to implement common date structures • Ie. Stacks and queues • Useful when dealing with multiple sheets or workbook • Set and Get • Example: Dim sh_info As Worksheet 'Pointer for worksheet Set sh_info = Worksheets.Add 'Make new work sheet sh_info.Name = "Info" 'Name new Work sheet

  8. Flow Control - For Statement • Example: Dim X as Integer For X = 1 To 10 Step 1 … Next X

  9. Flow Control - If Statement • Example: Dim X as Integer X = 1 If X < 100 Elseif Else End if

  10. Flow Control - While Statement • Example: Dim X as Integer X = 1 While X < 10 X = X + 1 Wend • See also DO … WHILE

  11. Flow Control - Slectect Statement • Example: Dim X as Double X = 1.25 Select Case X Case 1 Case 1.25 Case 1.5 End Select

  12. More Information

More Related