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

Operators in python
Operators in pythonOperators in python
Operators in python
deepalishinkar1
 
50g working with matricies
50g  working with matricies50g  working with matricies
50g working with matriciesEfrain Parizaca
 
Python : basic operators
Python : basic operatorsPython : basic operators
Python : basic operators
S.M. Salaquzzaman
 
Python Objects
Python ObjectsPython Objects
Python Objects
MuhammadBakri13
 
Function
FunctionFunction
Function
MuhammadBakri13
 
Operators in python
Operators in pythonOperators in python
Operators in python
eShikshak
 
Conditional Statements
Conditional StatementsConditional Statements
Conditional Statements
MuhammadBakri13
 
Matlab final year project in ludhiana
Matlab final year project in ludhianaMatlab final year project in ludhiana
Matlab final year project in ludhiana
deepikakaler1
 
Matlab final year project in jalandhar
Matlab final year project in jalandharMatlab final year project in jalandhar
Matlab final year project in jalandhar
deepikakaler1
 
Operators in Python
Operators in PythonOperators in Python
Operators in Python
Anusuya123
 
C++ revision add on till now
C++ revision add on till nowC++ revision add on till now
C++ revision add on till now
AmAn Singh
 
Looping
LoopingLooping
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
Jaspal Singh
 
MSc COMPUTER APPLICATION
MSc COMPUTER APPLICATIONMSc COMPUTER APPLICATION
MSc COMPUTER APPLICATION
MugdhaSharma11
 
Operator Precedence and Associativity
Operator Precedence and AssociativityOperator Precedence and Associativity
Operator Precedence and Associativity
Nicole Ynne Estabillo
 
Module iii part i
Module iii part iModule iii part i
Module iii part i
Sumaja Varma
 
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 Commands
Shameer 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 - ICA
emtrajano
 
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.ppt
JosephIThomas
 
Sterling Integrator Map Editor
Sterling Integrator Map EditorSterling Integrator Map Editor
Sterling Integrator Map EditorJeyhind M
 
Unit 5: Variables
Unit 5: VariablesUnit 5: Variables
Unit 5: Variables
Matthew Campbell, OCT
 
Excel Overview.pptx
Excel Overview.pptxExcel Overview.pptx
Excel Overview.pptx
NewmanLeke
 
Savitch Ch 02
Savitch Ch 02Savitch Ch 02
Savitch Ch 02
Terry Yoast
 
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
cwayne3
 
3 Formulas, Ranges, Functions.ppt
3 Formulas, Ranges, Functions.ppt3 Formulas, Ranges, Functions.ppt
3 Formulas, Ranges, Functions.ppt
AllanGuevarra1
 
Chapter 16-spreadsheet1 questions and answer
Chapter 16-spreadsheet1  questions and answerChapter 16-spreadsheet1  questions and answer
Chapter 16-spreadsheet1 questions and answer
RaajTech
 
Advanced Spreadsheet Skills-1.pptx
Advanced Spreadsheet Skills-1.pptxAdvanced Spreadsheet Skills-1.pptx
Advanced Spreadsheet Skills-1.pptx
CliffordBorromeo
 
Excel Training
Excel TrainingExcel Training
Excel Training
Joshua Flewelling
 
count^J Product^J functions.pptx
count^J Product^J functions.pptxcount^J Product^J functions.pptx
count^J Product^J functions.pptx
MdAquibRazi1
 
Advanced functions visual Basic .net
Advanced functions visual Basic .netAdvanced functions visual Basic .net
Advanced functions visual Basic .net
Mohammad Dwikat
 
Variables and calculations_chpt_4
Variables and calculations_chpt_4Variables and calculations_chpt_4
Variables and calculations_chpt_4
cmontanez
 
Data Handling
Data Handling Data Handling
Data Handling
bharath916489
 
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
SheryldeVilla2
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
Rakotoarison Louis Frederick
 

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

Cleaning The Part: Reclaim your Logging
Cleaning The Part: Reclaim your LoggingCleaning The Part: Reclaim your Logging
Cleaning The Part: Reclaim your Logging
Matthew Campbell, OCT
 
Building Bridges: A DevOps Story
Building Bridges:  A DevOps StoryBuilding Bridges:  A DevOps Story
Building Bridges: A DevOps Story
Matthew Campbell, OCT
 
Happy Teams Make Better Code
Happy Teams Make Better CodeHappy Teams Make Better Code
Happy Teams Make Better Code
Matthew Campbell, OCT
 
Real World Retrospectives
Real World RetrospectivesReal World Retrospectives
Real World Retrospectives
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/2Matthew Campbell, OCT
 
Chapter 2: Preliminaries
Chapter 2: PreliminariesChapter 2: Preliminaries
Chapter 2: Preliminaries
Matthew Campbell, OCT
 
Chapter 3 Excel Macros
Chapter 3 Excel MacrosChapter 3 Excel Macros
Chapter 3 Excel Macros
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

The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
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
Celine George
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
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
Steve Thomason
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 

Recently uploaded (20)

The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
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
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
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
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 

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