SlideShare a Scribd company logo
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 matriciesEfrain Parizaca
 
Operators in python
Operators in pythonOperators in python
Operators in pythoneShikshak
 
Matlab final year project in ludhiana
Matlab final year project in ludhianaMatlab final year project in ludhiana
Matlab final year project in ludhianadeepikakaler1
 
Matlab final year project in jalandhar
Matlab final year project in jalandharMatlab final year project in jalandhar
Matlab final year project in jalandhardeepikakaler1
 
Operators in Python
Operators in PythonOperators in Python
Operators in PythonAnusuya123
 
C++ revision add on till now
C++ revision add on till nowC++ revision add on till now
C++ revision add on till nowAmAn Singh
 
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 ExcelJaspal Singh
 
MSc COMPUTER APPLICATION
MSc COMPUTER APPLICATIONMSc COMPUTER APPLICATION
MSc COMPUTER APPLICATIONMugdhaSharma11
 
Operator Precedence and Associativity
Operator Precedence and AssociativityOperator Precedence and Associativity
Operator Precedence and AssociativityNicole Ynne Estabillo
 
Lesson 4 PowerPoint
Lesson 4 PowerPointLesson 4 PowerPoint
Lesson 4 PowerPointLinda Bodrie
 
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 CommandsShameer Ahmed Koya
 

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

Visual Basic Review - ICA
Visual Basic Review - ICAVisual Basic Review - ICA
Visual Basic Review - ICAemtrajano
 
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 Worksheetdpd
 
3 Formulas, Ranges, Functions.ppt
3 Formulas, Ranges, Functions.ppt3 Formulas, Ranges, Functions.ppt
3 Formulas, Ranges, Functions.pptJosephIThomas
 
Sterling Integrator Map Editor
Sterling Integrator Map EditorSterling Integrator Map Editor
Sterling Integrator Map EditorJeyhind M
 
Excel Overview.pptx
Excel Overview.pptxExcel Overview.pptx
Excel Overview.pptxNewmanLeke
 
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.docxcwayne3
 
3 Formulas, Ranges, Functions.ppt
3 Formulas, Ranges, Functions.ppt3 Formulas, Ranges, Functions.ppt
3 Formulas, Ranges, Functions.pptAllanGuevarra1
 
Chapter 16-spreadsheet1 questions and answer
Chapter 16-spreadsheet1  questions and answerChapter 16-spreadsheet1  questions and answer
Chapter 16-spreadsheet1 questions and answerRaajTech
 
Advanced Spreadsheet Skills-1.pptx
Advanced Spreadsheet Skills-1.pptxAdvanced Spreadsheet Skills-1.pptx
Advanced Spreadsheet Skills-1.pptxCliffordBorromeo
 
count^J Product^J functions.pptx
count^J Product^J functions.pptxcount^J Product^J functions.pptx
count^J Product^J functions.pptxMdAquibRazi1
 
Advanced functions visual Basic .net
Advanced functions visual Basic .netAdvanced functions visual Basic .net
Advanced functions visual Basic .netMohammad Dwikat
 
Variables and calculations_chpt_4
Variables and calculations_chpt_4Variables and calculations_chpt_4
Variables and calculations_chpt_4cmontanez
 
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.pptxSheryldeVilla2
 

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

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

Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesRased Khan
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxCeline George
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...Nguyen Thanh Tu Collection
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportAvinash Rai
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfQucHHunhnh
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringDenish Jangid
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxakshayaramakrishnan21
 
The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...sanghavirahi2
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxricssacare
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxjmorse8
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptSourabh Kumar
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxJenilouCasareno
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleCeline George
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePedroFerreira53928
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxheathfieldcps1
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryEugene Lysak
 

Recently uploaded (20)

Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptx
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptx
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. Henry
 

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