SlideShare a Scribd company logo
1 of 20
Excel Macros Level 1 Built-in Functions and Statements
Built-in Functions VBA has large number built-in functions and statements Some are shown in Table 7-1 (p. 78) and Table 7-2 (p. 80) 4/29/2010 M. Campbell - 2010 2 p. 78
Procedure Template SubChangeFormat(FontName [, FontSize]) Parameters listed in italics Optional parameters listed in [square brackets] Type declarations will be listed separately 4/29/2010 M. Campbell - 2010 3 p. 78
MsgBox MsgBox(prompt [, buttons] [, title]) prompt (String) Message to display in body buttons (Long) Sum of values to specify properties of message box See Table 7-2 for enum of argument values title (String) Message to display in title bar 4/29/2010 M. Campbell - 2010 4 p. 78
MsgBox MsgBox function returns number indicating which button pressed Defined as VbMsgBoxResult enumerator See Table 7-3 for return values 4/29/2010 M. Campbell - 2010 5 p. 78
Activities In the Unit 7 Activities complete: Activity 1: MsgBox Procedure 4/29/2010 M. Campbell - 2010 6
InputBox InputBox(prompt[, title] [, default]) prompt (String) Message to display title (String) Message to display in title bar default (String) Default value for the text box 4/29/2010 M. Campbell - 2010 7 p. 81
InputBox Returns the string the user enters in text box title (String) Message to display in title bar default (String) Default value for the text box 4/29/2010 M. Campbell - 2010 8 p. 81
Activities In the Unit 7 Activities complete: Activity 2: InputBox Subroutine 4/29/2010 M. Campbell - 2010 9
VBA String Functions Please review pages 82-84 especially: Len UCase and LCase Left, Right, and Mid Str and Val Trim, LTrim, and RTrim 4/29/2010 M. Campbell - 2010 10 p. 82
Activities In the Unit 7 Activities complete: Activity 3: Phone Number Processing 4/29/2010 M. Campbell - 2010 11
The Is Functions IsDate Returns true if variable is a date IsEmpty Returns true if variable is empty IsNull Returns true if variable is Null IsNumeric Returns true if variable is a numeric type 4/29/2010 M. Campbell - 2010 12 p. 85
Immediate If Function IIf(Expression, TruePart, FalsePart) If Expression is True returns TruePart If Expression is False returns FalsePart Always evaluates both parts Can lead to errors if one part should not be evaluated 4/29/2010 M. Campbell - 2010 13 p. 85
Switch Function Switch(expr1, value1, expr2, value2, _  		  … , exprn, valuen) When it finds an expression that matches it returns the corresponding value If no match is made returns Null 4/29/2010 M. Campbell - 2010 14 p. 86
Dim number As Variant Dim check As Integer number = Switch(check = 1, "one", _ 			 check = 2, "two", _ 			 check = 3, "three") If Not IsNull(number) Then Debug.Print(number) Else Debug.Print("Unrecognized number") End If 4/29/2010 M. Campbell - 2010 15
Units Conversion InchesToPoints(inchValue) PointsToInches(pointValue) Many Excel functions take values in points May prefer to work in inches 72 points in an inch 4/29/2010 M. Campbell - 2010 16 p. 87
Handling Errors VBA has methods to handle run-time errors Error handling is vital in applications meant for public release 4/29/2010 M. Campbell - 2010 17 p. 88
On Error Goto On Error GotoLabel If a run-time error occurs VBA will goto the code following the label 4/29/2010 M. Campbell - 2010 18 p. 88
On Error Resume Next On Error Resume Next VBA will continue executing code immediately following line that caused error 4/29/2010 M. Campbell - 2010 19 p. 90
Resume Statement Resume Resume with line that caused error Good if your code corrected the error Resume Next Resume with the line after the one that caused error Resume label Resume with code at line labelled label 4/29/2010 M. Campbell - 2010 20 p. 91

More Related Content

What's hot

50g working with matricies
50g  working with matricies50g  working with matricies
50g working with matricies
Efrain Parizaca
 
Lesson 4 PowerPoint
Lesson 4 PowerPointLesson 4 PowerPoint
Lesson 4 PowerPoint
Linda Bodrie
 

What's hot (18)

Operators in python
Operators in pythonOperators in python
Operators in python
 
50g working with matricies
50g  working with matricies50g  working with matricies
50g working with matricies
 
Python : basic operators
Python : basic operatorsPython : basic operators
Python : basic operators
 
Python Objects
Python ObjectsPython Objects
Python Objects
 
Function
FunctionFunction
Function
 
Operators in python
Operators in pythonOperators in python
Operators in python
 
Conditional Statements
Conditional StatementsConditional Statements
Conditional Statements
 
Matlab final year project in ludhiana
Matlab final year project in ludhianaMatlab final year project in ludhiana
Matlab final year project in ludhiana
 
Matlab final year project in jalandhar
Matlab final year project in jalandharMatlab final year project in jalandhar
Matlab final year project in jalandhar
 
Operators in Python
Operators in PythonOperators in Python
Operators in Python
 
C++ revision add on till now
C++ revision add on till nowC++ revision add on till now
C++ revision add on till now
 
Looping
LoopingLooping
Looping
 
How to use vlookup in MS Excel
How to use vlookup in MS ExcelHow to use vlookup in MS Excel
How to use vlookup in MS Excel
 
MSc COMPUTER APPLICATION
MSc COMPUTER APPLICATIONMSc COMPUTER APPLICATION
MSc COMPUTER APPLICATION
 
Operator Precedence and Associativity
Operator Precedence and AssociativityOperator Precedence and Associativity
Operator Precedence and Associativity
 
Module iii part i
Module iii part iModule iii part i
Module iii part i
 
Lesson 4 PowerPoint
Lesson 4 PowerPointLesson 4 PowerPoint
Lesson 4 PowerPoint
 
MATLAB programming tips 2 - Input and Output Commands
MATLAB programming tips 2 - Input and Output CommandsMATLAB programming tips 2 - Input and Output Commands
MATLAB programming tips 2 - Input and Output Commands
 

Similar to Unit 7: Built-In Functions

Excel Chapter 2 - Inserting Formulas in a Worksheet
Excel Chapter 2 - Inserting Formulas in a WorksheetExcel Chapter 2 - Inserting Formulas in a Worksheet
Excel Chapter 2 - Inserting Formulas in a Worksheet
dpd
 
Sterling Integrator Map Editor
Sterling Integrator Map EditorSterling Integrator Map Editor
Sterling Integrator Map Editor
Jeyhind M
 
Advanced Spreadsheet Skills-1.pptx
Advanced Spreadsheet Skills-1.pptxAdvanced Spreadsheet Skills-1.pptx
Advanced Spreadsheet Skills-1.pptx
CliffordBorromeo
 

Similar to Unit 7: Built-In Functions (20)

Visual Basic Review - ICA
Visual Basic Review - ICAVisual Basic Review - ICA
Visual Basic Review - ICA
 
Excel Chapter 2 - Inserting Formulas in a Worksheet
Excel Chapter 2 - Inserting Formulas in a WorksheetExcel Chapter 2 - Inserting Formulas in a Worksheet
Excel Chapter 2 - Inserting Formulas in a Worksheet
 
Excel300
Excel300Excel300
Excel300
 
3 Formulas, Ranges, Functions.ppt
3 Formulas, Ranges, Functions.ppt3 Formulas, Ranges, Functions.ppt
3 Formulas, Ranges, Functions.ppt
 
Sterling Integrator Map Editor
Sterling Integrator Map EditorSterling Integrator Map Editor
Sterling Integrator Map Editor
 
Unit 5: Variables
Unit 5: VariablesUnit 5: Variables
Unit 5: Variables
 
Excel Overview.pptx
Excel Overview.pptxExcel Overview.pptx
Excel Overview.pptx
 
Savitch Ch 02
Savitch Ch 02Savitch Ch 02
Savitch Ch 02
 
Savitch Ch 02
Savitch Ch 02Savitch Ch 02
Savitch Ch 02
 
I am trying to create a code that will show an error if someone puts a.docx
I am trying to create a code that will show an error if someone puts a.docxI am trying to create a code that will show an error if someone puts a.docx
I am trying to create a code that will show an error if someone puts a.docx
 
3 Formulas, Ranges, Functions.ppt
3 Formulas, Ranges, Functions.ppt3 Formulas, Ranges, Functions.ppt
3 Formulas, Ranges, Functions.ppt
 
Chapter 16-spreadsheet1 questions and answer
Chapter 16-spreadsheet1  questions and answerChapter 16-spreadsheet1  questions and answer
Chapter 16-spreadsheet1 questions and answer
 
Advanced Spreadsheet Skills-1.pptx
Advanced Spreadsheet Skills-1.pptxAdvanced Spreadsheet Skills-1.pptx
Advanced Spreadsheet Skills-1.pptx
 
Excel Training
Excel TrainingExcel Training
Excel Training
 
count^J Product^J functions.pptx
count^J Product^J functions.pptxcount^J Product^J functions.pptx
count^J Product^J functions.pptx
 
Advanced functions visual Basic .net
Advanced functions visual Basic .netAdvanced functions visual Basic .net
Advanced functions visual Basic .net
 
Variables and calculations_chpt_4
Variables and calculations_chpt_4Variables and calculations_chpt_4
Variables and calculations_chpt_4
 
Data Handling
Data Handling Data Handling
Data Handling
 
9 - Advanced Functions in MS Excel.pptx
9 - Advanced Functions in MS Excel.pptx9 - Advanced Functions in MS Excel.pptx
9 - Advanced Functions in MS Excel.pptx
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 

More from Matthew Campbell, OCT

Unit 6: Functions and Subroutines - Part 2/2
Unit 6: Functions and Subroutines - Part 2/2Unit 6: Functions and Subroutines - Part 2/2
Unit 6: Functions and Subroutines - Part 2/2
Matthew Campbell, OCT
 

More from Matthew Campbell, OCT (9)

Cleaning The Part: Reclaim your Logging
Cleaning The Part: Reclaim your LoggingCleaning The Part: Reclaim your Logging
Cleaning The Part: Reclaim your Logging
 
Building Bridges: A DevOps Story
Building Bridges:  A DevOps StoryBuilding Bridges:  A DevOps Story
Building Bridges: A DevOps Story
 
Happy Teams Make Better Code
Happy Teams Make Better CodeHappy Teams Make Better Code
Happy Teams Make Better Code
 
Real World Retrospectives
Real World RetrospectivesReal World Retrospectives
Real World Retrospectives
 
Unit 8: Control Statements
Unit 8: Control StatementsUnit 8: Control Statements
Unit 8: Control Statements
 
Unit 6: Functions and Subroutines
Unit 6: Functions and SubroutinesUnit 6: Functions and Subroutines
Unit 6: Functions and Subroutines
 
Unit 6: Functions and Subroutines - Part 2/2
Unit 6: Functions and Subroutines - Part 2/2Unit 6: Functions and Subroutines - Part 2/2
Unit 6: Functions and Subroutines - Part 2/2
 
Chapter 2: Preliminaries
Chapter 2: PreliminariesChapter 2: Preliminaries
Chapter 2: Preliminaries
 
Chapter 3 Excel Macros
Chapter 3 Excel MacrosChapter 3 Excel Macros
Chapter 3 Excel Macros
 

Recently uploaded

會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
Poster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdfPoster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdf
Alexander Litvinenko
 

Recently uploaded (20)

When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17
 
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
 
How to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 InventoryHow to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 Inventory
 
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING IIII BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
IPL Online Quiz by Pragya; Question Set.
IPL Online Quiz by Pragya; Question Set.IPL Online Quiz by Pragya; Question Set.
IPL Online Quiz by Pragya; Question Set.
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
 
Poster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdfPoster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdf
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 

Unit 7: Built-In Functions

  • 1. Excel Macros Level 1 Built-in Functions and Statements
  • 2. Built-in Functions VBA has large number built-in functions and statements Some are shown in Table 7-1 (p. 78) and Table 7-2 (p. 80) 4/29/2010 M. Campbell - 2010 2 p. 78
  • 3. Procedure Template SubChangeFormat(FontName [, FontSize]) Parameters listed in italics Optional parameters listed in [square brackets] Type declarations will be listed separately 4/29/2010 M. Campbell - 2010 3 p. 78
  • 4. MsgBox MsgBox(prompt [, buttons] [, title]) prompt (String) Message to display in body buttons (Long) Sum of values to specify properties of message box See Table 7-2 for enum of argument values title (String) Message to display in title bar 4/29/2010 M. Campbell - 2010 4 p. 78
  • 5. MsgBox MsgBox function returns number indicating which button pressed Defined as VbMsgBoxResult enumerator See Table 7-3 for return values 4/29/2010 M. Campbell - 2010 5 p. 78
  • 6. Activities In the Unit 7 Activities complete: Activity 1: MsgBox Procedure 4/29/2010 M. Campbell - 2010 6
  • 7. InputBox InputBox(prompt[, title] [, default]) prompt (String) Message to display title (String) Message to display in title bar default (String) Default value for the text box 4/29/2010 M. Campbell - 2010 7 p. 81
  • 8. InputBox Returns the string the user enters in text box title (String) Message to display in title bar default (String) Default value for the text box 4/29/2010 M. Campbell - 2010 8 p. 81
  • 9. Activities In the Unit 7 Activities complete: Activity 2: InputBox Subroutine 4/29/2010 M. Campbell - 2010 9
  • 10. VBA String Functions Please review pages 82-84 especially: Len UCase and LCase Left, Right, and Mid Str and Val Trim, LTrim, and RTrim 4/29/2010 M. Campbell - 2010 10 p. 82
  • 11. Activities In the Unit 7 Activities complete: Activity 3: Phone Number Processing 4/29/2010 M. Campbell - 2010 11
  • 12. The Is Functions IsDate Returns true if variable is a date IsEmpty Returns true if variable is empty IsNull Returns true if variable is Null IsNumeric Returns true if variable is a numeric type 4/29/2010 M. Campbell - 2010 12 p. 85
  • 13. Immediate If Function IIf(Expression, TruePart, FalsePart) If Expression is True returns TruePart If Expression is False returns FalsePart Always evaluates both parts Can lead to errors if one part should not be evaluated 4/29/2010 M. Campbell - 2010 13 p. 85
  • 14. Switch Function Switch(expr1, value1, expr2, value2, _ … , exprn, valuen) When it finds an expression that matches it returns the corresponding value If no match is made returns Null 4/29/2010 M. Campbell - 2010 14 p. 86
  • 15. Dim number As Variant Dim check As Integer number = Switch(check = 1, "one", _ check = 2, "two", _ check = 3, "three") If Not IsNull(number) Then Debug.Print(number) Else Debug.Print("Unrecognized number") End If 4/29/2010 M. Campbell - 2010 15
  • 16. Units Conversion InchesToPoints(inchValue) PointsToInches(pointValue) Many Excel functions take values in points May prefer to work in inches 72 points in an inch 4/29/2010 M. Campbell - 2010 16 p. 87
  • 17. Handling Errors VBA has methods to handle run-time errors Error handling is vital in applications meant for public release 4/29/2010 M. Campbell - 2010 17 p. 88
  • 18. On Error Goto On Error GotoLabel If a run-time error occurs VBA will goto the code following the label 4/29/2010 M. Campbell - 2010 18 p. 88
  • 19. On Error Resume Next On Error Resume Next VBA will continue executing code immediately following line that caused error 4/29/2010 M. Campbell - 2010 19 p. 90
  • 20. Resume Statement Resume Resume with line that caused error Good if your code corrected the error Resume Next Resume with the line after the one that caused error Resume label Resume with code at line labelled label 4/29/2010 M. Campbell - 2010 20 p. 91