SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Semelhante a 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
 

Semelhante a 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
 

Mais de Matthew Campbell, OCT

Mais de 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
 

Último

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
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
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
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
 
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
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 

Último (20)

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
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
 
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
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 

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