SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von Matthew Campbell, OCT

Mehr von 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
 

Kürzlich hochgeladen

SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
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
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxdhanalakshmis0310
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
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
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 

Kürzlich hochgeladen (20)

SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
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
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.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
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
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
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 

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