SlideShare uma empresa Scribd logo
1 de 21
Intro to VBA
Programming
Ivey Technology Club
Intro to VBA Programming

Agenda
 Variables




Types
Declaration
Assignment

 Functions/Subroutines



Parameters
Returning values

 Loops



While
For
Intro to VBA Programming

Agenda
 Variables




Types
Declaration
Assignment

 Functions/Subroutines



Parameters
Returning values

 Loops



While
For
Intro to VBA Programming

 You‟ve

seen variables before

X

=5
Y=X+3
 Variables

can be reused and changed

X

=5
X=2
X=X+7
 The

same principles apply in
programming
Variables

Functions

Loops
Intro to VBA Programming

 Computers

are stupid

 Must

tell them exactly what to do
 The more we tell them, the faster they run
 Each

language does this differently

 We

will focus on VBA

Variables

Functions

Loops
Intro to VBA Programming

 All

variables should be declared first

 This

will prevent hard to find errors

 It

is not required that you do so, but HIGHLY
encouraged

 To

force yourself, use “Option Explicit” at the
beginning of VBA files

Variables

Functions

Loops
Intro to VBA Programming

 To

declare a variable in VBA, the basic
structure is:
Dim <name> as <type>
Ex. Dim X as Integer

Variables

Functions

Loops
Intro to VBA Programming

 Dim

means “new Dimension”

 Fancy

VBA way of saying new variable

 When

declaring a variable, you should
know what it will be used for

 Different

variable types are used to store
different data

Variables

Functions

Loops
Intro to VBA Programming

 Types

include:

 Integer

(whole numbers like 3)
 Float (decimal numbers like 1.25)
 Double (just like float, can store wider range
of values)
 Characters (like „a‟)
 String (a number of characters in a row such
as “Ivey”)
 MANY

Variables

more

Functions

Loops
Intro to VBA Programming

 Types

include:

 Integer

(whole numbers like 3)
 Float (decimal numbers like 1.25)
 Double (just like float, can store wider range
of values)
 Characters (like „a‟)
 String (a number of characters in a row such
as “Ivey”)
 MANY

Variables

more

Functions

Loops
Intro to VBA Programming

 To

assign a value to a use the “=“
operator
 Ex.

Dim x As Integer (declare the variable)
x=5

Variables

Functions

Loops
Intro to VBA Programming

Agenda
 Variables




Types
Declaration
Assignment

 Functions/Subroutines



Parameters
Returning values

 Loops



While
For
Intro to VBA Programming

Functions
 Take

in input, process it, and produce
output

Variables

Functions

Loops
Intro to VBA Programming

 Functions
 General

must also be declared

format of function declaration:

Function <name>(ByVal <parameterName> As <type>) As <returnType>

 Subroutines

are declared the same way,
but do not have a return type

Variables

Functions

Loops
Intro to VBA Programming

 ByVal

refers to “by value”

 This

will make a copy of the variable and its
value

 ByRef

could also be used

 This

 Don‟t

will modify the original variable

worry too much about this for now

Variables

Functions

Loops
Intro to VBA Programming

 To

explicitly return a value from a
function, assign the return value to the
function name itself

Variables

Functions

Loops
Intro to VBA Programming

 Subroutines

are the same as functions,
except for 2 important differences:
1.

They do not have explicit return types

2.

They cannot be used directly in the
spreadsheet

Variables

Functions

Loops
Intro to VBA Programming

Agenda
 Variables




Types
Declaration
Assignment

 Functions/Subroutines



Parameters
Returning values

 Loops



While
For
Intro to VBA Programming

Loops
 Loops

allow us to repeatedly perform the
same task easily

 There

are different kinds of loops
including:
 While
 Until
 For

Variables

Functions

Loops
Intro to VBA Programming

 “While”

true

 “Until”

true

loops while a certain condition is

loops until a certain condition is

 “For”

loops for a specified number of
iterations

Variables

Functions

Loops
Intro to VBA Programming

Questions, anyone ?

Mais conteúdo relacionado

Mais procurados

E learning excel vba programming lesson 3
E learning excel vba programming  lesson 3E learning excel vba programming  lesson 3
E learning excel vba programming lesson 3Vijay Perepa
 
E learning excel vba programming lesson 2
E learning excel vba programming  lesson 2E learning excel vba programming  lesson 2
E learning excel vba programming lesson 2Vijay Perepa
 
Excel VBA programming basics
Excel VBA programming basicsExcel VBA programming basics
Excel VBA programming basicsHang Dong
 
E learning excel vba programming lesson 1
E learning excel vba programming  lesson 1E learning excel vba programming  lesson 1
E learning excel vba programming lesson 1Vijay Perepa
 
Transforming Power Point Show with VBA
Transforming Power Point Show with VBATransforming Power Point Show with VBA
Transforming Power Point Show with VBADCPS
 
Advance MS Excel
Advance MS ExcelAdvance MS Excel
Advance MS Excelacute23
 
AVB201.2 Microsoft Access VBA Module 2
AVB201.2 Microsoft Access VBA Module 2AVB201.2 Microsoft Access VBA Module 2
AVB201.2 Microsoft Access VBA Module 2Dan D'Urso
 
Creating A User‑Defined Function In Excel Using Vba
Creating A User‑Defined Function In Excel Using VbaCreating A User‑Defined Function In Excel Using Vba
Creating A User‑Defined Function In Excel Using VbaChester Tugwell
 
Visual Basics for Application
Visual Basics for Application Visual Basics for Application
Visual Basics for Application Raghu nath
 
AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1guest38bf
 
Access tips access and sql part 2 putting vba and sql together
Access tips  access and sql part 2  putting vba and sql togetherAccess tips  access and sql part 2  putting vba and sql together
Access tips access and sql part 2 putting vba and sql togetherquest2900
 

Mais procurados (20)

E learning excel vba programming lesson 3
E learning excel vba programming  lesson 3E learning excel vba programming  lesson 3
E learning excel vba programming lesson 3
 
Vba Class Level 1
Vba Class Level 1Vba Class Level 1
Vba Class Level 1
 
E learning excel vba programming lesson 2
E learning excel vba programming  lesson 2E learning excel vba programming  lesson 2
E learning excel vba programming lesson 2
 
Vba introduction
Vba introductionVba introduction
Vba introduction
 
Excel VBA programming basics
Excel VBA programming basicsExcel VBA programming basics
Excel VBA programming basics
 
E learning excel vba programming lesson 1
E learning excel vba programming  lesson 1E learning excel vba programming  lesson 1
E learning excel vba programming lesson 1
 
Vba
Vba Vba
Vba
 
Excel vba
Excel vbaExcel vba
Excel vba
 
VBA
VBAVBA
VBA
 
Transforming Power Point Show with VBA
Transforming Power Point Show with VBATransforming Power Point Show with VBA
Transforming Power Point Show with VBA
 
Vba Class Level 3
Vba Class Level 3Vba Class Level 3
Vba Class Level 3
 
Advance MS Excel
Advance MS ExcelAdvance MS Excel
Advance MS Excel
 
AVB201.2 Microsoft Access VBA Module 2
AVB201.2 Microsoft Access VBA Module 2AVB201.2 Microsoft Access VBA Module 2
AVB201.2 Microsoft Access VBA Module 2
 
Creating A User‑Defined Function In Excel Using Vba
Creating A User‑Defined Function In Excel Using VbaCreating A User‑Defined Function In Excel Using Vba
Creating A User‑Defined Function In Excel Using Vba
 
Visual Basics for Application
Visual Basics for Application Visual Basics for Application
Visual Basics for Application
 
AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1
 
07 java variables
07   java variables07   java variables
07 java variables
 
Access tips access and sql part 2 putting vba and sql together
Access tips  access and sql part 2  putting vba and sql togetherAccess tips  access and sql part 2  putting vba and sql together
Access tips access and sql part 2 putting vba and sql together
 
Fieldsymbols
FieldsymbolsFieldsymbols
Fieldsymbols
 
Operators in java By cheena
Operators in java By cheenaOperators in java By cheena
Operators in java By cheena
 

Semelhante a Intro to Excel VBA Programming

200 Mega eBook Collection- http://bit.ly/3WEZuYJ
200 Mega eBook Collection- http://bit.ly/3WEZuYJ200 Mega eBook Collection- http://bit.ly/3WEZuYJ
200 Mega eBook Collection- http://bit.ly/3WEZuYJDannySingh23
 
Financial modeling sameh aljabli lecture 6
Financial modeling   sameh aljabli   lecture 6Financial modeling   sameh aljabli   lecture 6
Financial modeling sameh aljabli lecture 6Sameh Algabli
 
Unit 3-Javascript.pptx
Unit 3-Javascript.pptxUnit 3-Javascript.pptx
Unit 3-Javascript.pptxAmanJha533833
 
Handout # 4 functions + scopes
Handout # 4   functions + scopes Handout # 4   functions + scopes
Handout # 4 functions + scopes NUST Stuff
 
Notes5
Notes5Notes5
Notes5hccit
 
Vb script tutorial for qtp[1]
Vb script tutorial for qtp[1]Vb script tutorial for qtp[1]
Vb script tutorial for qtp[1]srikanthbkm
 
Arrays &amp; functions in php
Arrays &amp; functions in phpArrays &amp; functions in php
Arrays &amp; functions in phpAshish Chamoli
 
04. WORKING WITH FUNCTIONS-2 (1).pptx
04. WORKING WITH FUNCTIONS-2 (1).pptx04. WORKING WITH FUNCTIONS-2 (1).pptx
04. WORKING WITH FUNCTIONS-2 (1).pptxManas40552
 
Functions in c++, presentation, short and sweet presentation, and details of ...
Functions in c++, presentation, short and sweet presentation, and details of ...Functions in c++, presentation, short and sweet presentation, and details of ...
Functions in c++, presentation, short and sweet presentation, and details of ...Sar
 
Functional JavaScript Fundamentals
Functional JavaScript FundamentalsFunctional JavaScript Fundamentals
Functional JavaScript FundamentalsSrdjan Strbanovic
 

Semelhante a Intro to Excel VBA Programming (20)

200 Mega eBook Collection- http://bit.ly/3WEZuYJ
200 Mega eBook Collection- http://bit.ly/3WEZuYJ200 Mega eBook Collection- http://bit.ly/3WEZuYJ
200 Mega eBook Collection- http://bit.ly/3WEZuYJ
 
Intro to Scala
 Intro to Scala Intro to Scala
Intro to Scala
 
Financial modeling sameh aljabli lecture 6
Financial modeling   sameh aljabli   lecture 6Financial modeling   sameh aljabli   lecture 6
Financial modeling sameh aljabli lecture 6
 
Unit 3-Javascript.pptx
Unit 3-Javascript.pptxUnit 3-Javascript.pptx
Unit 3-Javascript.pptx
 
functions new.pptx
functions new.pptxfunctions new.pptx
functions new.pptx
 
Handout # 4 functions + scopes
Handout # 4   functions + scopes Handout # 4   functions + scopes
Handout # 4 functions + scopes
 
Notes5
Notes5Notes5
Notes5
 
C functions
C functionsC functions
C functions
 
Improved VBA support
Improved VBA supportImproved VBA support
Improved VBA support
 
Unit 2.5
Unit 2.5Unit 2.5
Unit 2.5
 
MA3696 Lecture 9
MA3696 Lecture 9MA3696 Lecture 9
MA3696 Lecture 9
 
Vb script tutorial for qtp[1]
Vb script tutorial for qtp[1]Vb script tutorial for qtp[1]
Vb script tutorial for qtp[1]
 
Javascript functions
Javascript functionsJavascript functions
Javascript functions
 
Arrays &amp; functions in php
Arrays &amp; functions in phpArrays &amp; functions in php
Arrays &amp; functions in php
 
Qtp vb scripting
Qtp vb scriptingQtp vb scripting
Qtp vb scripting
 
Unit 2.5
Unit 2.5Unit 2.5
Unit 2.5
 
04. WORKING WITH FUNCTIONS-2 (1).pptx
04. WORKING WITH FUNCTIONS-2 (1).pptx04. WORKING WITH FUNCTIONS-2 (1).pptx
04. WORKING WITH FUNCTIONS-2 (1).pptx
 
Functions in c++, presentation, short and sweet presentation, and details of ...
Functions in c++, presentation, short and sweet presentation, and details of ...Functions in c++, presentation, short and sweet presentation, and details of ...
Functions in c++, presentation, short and sweet presentation, and details of ...
 
Functional JavaScript Fundamentals
Functional JavaScript FundamentalsFunctional JavaScript Fundamentals
Functional JavaScript Fundamentals
 
Ma3696 Lecture 3
Ma3696 Lecture 3Ma3696 Lecture 3
Ma3696 Lecture 3
 

Último

HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 

Último (20)

HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 

Intro to Excel VBA Programming

  • 2. Intro to VBA Programming Agenda  Variables    Types Declaration Assignment  Functions/Subroutines   Parameters Returning values  Loops   While For
  • 3. Intro to VBA Programming Agenda  Variables    Types Declaration Assignment  Functions/Subroutines   Parameters Returning values  Loops   While For
  • 4. Intro to VBA Programming  You‟ve seen variables before X =5 Y=X+3  Variables can be reused and changed X =5 X=2 X=X+7  The same principles apply in programming Variables Functions Loops
  • 5. Intro to VBA Programming  Computers are stupid  Must tell them exactly what to do  The more we tell them, the faster they run  Each language does this differently  We will focus on VBA Variables Functions Loops
  • 6. Intro to VBA Programming  All variables should be declared first  This will prevent hard to find errors  It is not required that you do so, but HIGHLY encouraged  To force yourself, use “Option Explicit” at the beginning of VBA files Variables Functions Loops
  • 7. Intro to VBA Programming  To declare a variable in VBA, the basic structure is: Dim <name> as <type> Ex. Dim X as Integer Variables Functions Loops
  • 8. Intro to VBA Programming  Dim means “new Dimension”  Fancy VBA way of saying new variable  When declaring a variable, you should know what it will be used for  Different variable types are used to store different data Variables Functions Loops
  • 9. Intro to VBA Programming  Types include:  Integer (whole numbers like 3)  Float (decimal numbers like 1.25)  Double (just like float, can store wider range of values)  Characters (like „a‟)  String (a number of characters in a row such as “Ivey”)  MANY Variables more Functions Loops
  • 10. Intro to VBA Programming  Types include:  Integer (whole numbers like 3)  Float (decimal numbers like 1.25)  Double (just like float, can store wider range of values)  Characters (like „a‟)  String (a number of characters in a row such as “Ivey”)  MANY Variables more Functions Loops
  • 11. Intro to VBA Programming  To assign a value to a use the “=“ operator  Ex. Dim x As Integer (declare the variable) x=5 Variables Functions Loops
  • 12. Intro to VBA Programming Agenda  Variables    Types Declaration Assignment  Functions/Subroutines   Parameters Returning values  Loops   While For
  • 13. Intro to VBA Programming Functions  Take in input, process it, and produce output Variables Functions Loops
  • 14. Intro to VBA Programming  Functions  General must also be declared format of function declaration: Function <name>(ByVal <parameterName> As <type>) As <returnType>  Subroutines are declared the same way, but do not have a return type Variables Functions Loops
  • 15. Intro to VBA Programming  ByVal refers to “by value”  This will make a copy of the variable and its value  ByRef could also be used  This  Don‟t will modify the original variable worry too much about this for now Variables Functions Loops
  • 16. Intro to VBA Programming  To explicitly return a value from a function, assign the return value to the function name itself Variables Functions Loops
  • 17. Intro to VBA Programming  Subroutines are the same as functions, except for 2 important differences: 1. They do not have explicit return types 2. They cannot be used directly in the spreadsheet Variables Functions Loops
  • 18. Intro to VBA Programming Agenda  Variables    Types Declaration Assignment  Functions/Subroutines   Parameters Returning values  Loops   While For
  • 19. Intro to VBA Programming Loops  Loops allow us to repeatedly perform the same task easily  There are different kinds of loops including:  While  Until  For Variables Functions Loops
  • 20. Intro to VBA Programming  “While” true  “Until” true loops while a certain condition is loops until a certain condition is  “For” loops for a specified number of iterations Variables Functions Loops
  • 21. Intro to VBA Programming Questions, anyone ?