SlideShare ist ein Scribd-Unternehmen logo
1 von 13
Presented By:
Abhishek Rajoria
• Excel is object based model…
• Objects include things such as application, workbook, worksheet, cells
• Each object has properties
• Color, border, value, name
Macros execute tasks according to instructions. Macros do not think…
• Everything you do can be expressed in code (instructions); it is stored the
same way.
• Each time you do anything in Excel the same action can be expressed in code.
• You interact with excel through an interface that makes the code easier to
understand/intuit.
• Choosing the “sheet1” sheet is expressed as; Sheets(“sheet1”).Select
• It saves time giving you more time to work on higher level tasks
• VBA can do things more quickly than you can.
• It standardizes processes, eliminates error due to deviation from
instructions
• It will do the exact same thing each time it runs
• When you are doing a routine task that you can write VERY
good instructions for doing, you can likely automate that task by
using VBA.
• We won‟t use it when abstract thinking or problem solving is a
necessary component of the task or when there are any new
variables present in our current task.
• Developer tab – first you show get access
• Record a macro button – in Developer tab
• Alt + F11 show the VBE; Visual Basic Editor
• Tour of VBA code area
• Project tree, object properties, space for code
• Recording
• Button
• Naming – no spaces; use underscores or caps
• Save in a Workbook
• Save in Personal workbook
• What is personal workbook
• How to open it for the first time
• Once you save a macro it opens each time you open Excel
• Always hidden.
• If you unhide PW and close excel, PW will close!
• To re-open; C:Documents and SettingsusernameApplication
DataMicrosoftExcelXLSTART – Application Data file is hidden!
• How to call the macro – from Developer tab
• Save workbook as .xlsm or you will lose your work!
Standard R1C1
=A1+1 =RC[-1]+1
=$A$1+1 =R1C1+1
=$A1+1 =RC1+1
=A$1+1 =R1C[-1]+1
=Sum(A1:A10) =Sum(RC[-1]:R[9]C[-1])
=Sum($A$1:$A$10) =Sum(R1C1:R10C1)
• Module subroutines
• Show what recording does
• Walk through example
• Show excess that gets recorded and then how to spot and clean
• R1C1 syntax vs. Regular
• What is R1C1?
• What does R1C1 syntax look like and how to convert? (formula
in B1)
• Break mode
• When running code produces error you get break mode to fix error and prevent
code from continuing or application running.
• Sometimes nothing works! Maybe you‟re in break mode?
• How to tell and how to tell (in title and yellow highlighting)
• How to get out of break mode.
• Notes in VBA code
• How to write notes “ „ “
• Why to write them
• Break code into chunks by function
• Record sections of code if you don‟t know syntax
• How to run code from VBE
• Call Macro from Excel, F5 in VBA, or “run” from drop-down
• How to break code if it keeps going
• Show from example
• How to create dynamic row length (create example where we see
the problem to illustrate problem solving tactic)
• Declaring variables using Dim xxx as xxx
• Substitute variable for specific reference in code
• Code upon a user action
In VBA Editor select workbook object
• Change left drop-down box to “workbook”
• Change right drop-down box to desired action
• Place code within the newly create subroutine boundaries
• Loops
• For
Syntax and example
• If
Syntax and example
• Do While
Syntax and example
• Example of code/program
• Buttons and things
• Where to insert buttons
• How to assign code to buttons
• Userforms
• Awesome but code gets more complex
• Don‟t forget objects have values – radio button.value can
be true or false
• Macros run from wherever you call them if you call them on the wrong
sheet the result can be really bad
• Use Sheets(“sheetname”).Select to make sure it always goes
to the right sheet before you call it
• Usage of message boxes to check code – msgbox “stop”
• Problem: with filters being off and on and errors – they need to be
correct or you‟ll get errors
• Problem: with sheets being hidden and referencing them for actions
• Error handling
• If it is possible that your code will generate an error you don‟t want
your code to stop running. Need to tell it to do so b/c by default it
stops. 2 methods:
• On Error Goto Next
• On Error Goto 0
• Syntax in VBA and Excel is not the same…. Of course
• Use msgboxes to help see if your code is right
• More quotes are needed.
• Create a UI with hiding sheets
• Create codes that show and hide sheets so that when an action is taken
you go to a different part of a workbook. This turns a workbook into an
application.
• Save before you run, extremely hard to undo macros
• The best code never uses the “select” code! Each time this happens it slows
down the code. See if you can find ways to only use VBA.
• Example: Paste special values formula can be written as
„Range(“A3”).Value = Range(“A3”).Value‟
Excel VBA Macros for Automation and Efficiency

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to Excel VBA/Macros
Introduction to Excel VBA/MacrosIntroduction to Excel VBA/Macros
Introduction to Excel VBA/Macrosarttan2001
 
Excel VBA programming basics
Excel VBA programming basicsExcel VBA programming basics
Excel VBA programming basicsHang Dong
 
An introduction to microsoft office 2007 lecture
An introduction to microsoft office 2007 lectureAn introduction to microsoft office 2007 lecture
An introduction to microsoft office 2007 lectureSukh Sandhu
 
Creating a Microsoft Excel Macro
Creating a Microsoft Excel MacroCreating a Microsoft Excel Macro
Creating a Microsoft Excel MacroLauraly DuBois
 
Introduction to MS WORD
Introduction to MS WORDIntroduction to MS WORD
Introduction to MS WORDMuhammad Irfan
 
Word 2007 Presentation
Word 2007 PresentationWord 2007 Presentation
Word 2007 PresentationKristen T
 
A Quick Simple MS Excel Macro
A Quick Simple MS Excel MacroA Quick Simple MS Excel Macro
A Quick Simple MS Excel MacroPranav Ghode
 
MS Word tips and tricks
MS Word tips and tricksMS Word tips and tricks
MS Word tips and trickssutrainer
 
Introduction To Excel 2007 Macros
Introduction To Excel 2007 MacrosIntroduction To Excel 2007 Macros
Introduction To Excel 2007 MacrosExcel
 

Was ist angesagt? (20)

Vba
Vba Vba
Vba
 
An introduction to vba and macros
An introduction to vba and macrosAn introduction to vba and macros
An introduction to vba and macros
 
Excel macro
Excel macroExcel macro
Excel macro
 
Introduction to Excel VBA/Macros
Introduction to Excel VBA/MacrosIntroduction to Excel VBA/Macros
Introduction to Excel VBA/Macros
 
Excel VBA programming basics
Excel VBA programming basicsExcel VBA programming basics
Excel VBA programming basics
 
Excel Macro Magic
Excel Macro MagicExcel Macro Magic
Excel Macro Magic
 
An introduction to microsoft office 2007 lecture
An introduction to microsoft office 2007 lectureAn introduction to microsoft office 2007 lecture
An introduction to microsoft office 2007 lecture
 
Creating a Microsoft Excel Macro
Creating a Microsoft Excel MacroCreating a Microsoft Excel Macro
Creating a Microsoft Excel Macro
 
MS Word 2007
MS Word 2007MS Word 2007
MS Word 2007
 
Introduction to MS WORD
Introduction to MS WORDIntroduction to MS WORD
Introduction to MS WORD
 
Word 2007 Presentation
Word 2007 PresentationWord 2007 Presentation
Word 2007 Presentation
 
A Quick Simple MS Excel Macro
A Quick Simple MS Excel MacroA Quick Simple MS Excel Macro
A Quick Simple MS Excel Macro
 
Ms excel
Ms excelMs excel
Ms excel
 
MS Excel 2013
MS Excel 2013MS Excel 2013
MS Excel 2013
 
Basic Debugging
Basic DebuggingBasic Debugging
Basic Debugging
 
Ms excell
Ms excellMs excell
Ms excell
 
M.S EXCEL
M.S EXCELM.S EXCEL
M.S EXCEL
 
MS Word tips and tricks
MS Word tips and tricksMS Word tips and tricks
MS Word tips and tricks
 
Introduction To Excel 2007 Macros
Introduction To Excel 2007 MacrosIntroduction To Excel 2007 Macros
Introduction To Excel 2007 Macros
 
Presentation
PresentationPresentation
Presentation
 

Andere mochten auch

Advanced Microsoft Excel
Advanced Microsoft ExcelAdvanced Microsoft Excel
Advanced Microsoft ExcelEric Metelka
 
985 paper presentation -banff 2015
985 paper presentation -banff 2015985 paper presentation -banff 2015
985 paper presentation -banff 2015Chuck Eesley
 
Service tax procedure in india aces for all assesses
Service tax procedure in india   aces for all assessesService tax procedure in india   aces for all assesses
Service tax procedure in india aces for all assessesChandan Singh
 
新觀念的VB6教本ch12
新觀念的VB6教本ch12新觀念的VB6教本ch12
新觀念的VB6教本ch12jameschsc
 
新觀念的VB6教本ch11
新觀念的VB6教本ch11新觀念的VB6教本ch11
新觀念的VB6教本ch11jameschsc
 
新觀念的VB6教本ch13
新觀念的VB6教本ch13新觀念的VB6教本ch13
新觀念的VB6教本ch13jameschsc
 
新觀念的VB6教本ch04
新觀念的VB6教本ch04新觀念的VB6教本ch04
新觀念的VB6教本ch04jameschsc
 
Demystifying Mergers and Acquisition
Demystifying Mergers and AcquisitionDemystifying Mergers and Acquisition
Demystifying Mergers and AcquisitionSiddhant Bahal
 
Management productivity tools1
Management productivity tools1Management productivity tools1
Management productivity tools1Hari Krishnan
 
新觀念的VB6教本ch03
新觀念的VB6教本ch03新觀念的VB6教本ch03
新觀念的VB6教本ch03jameschsc
 
新觀念的VB6教本ch02
新觀念的VB6教本ch02新觀念的VB6教本ch02
新觀念的VB6教本ch02jameschsc
 
新觀念的VB6教本ch08
新觀念的VB6教本ch08新觀念的VB6教本ch08
新觀念的VB6教本ch08jameschsc
 
SolidWorks Design Automation Using the SolidWorks API, Microsoft Excel and VBA
SolidWorks Design Automation Using the SolidWorks API, Microsoft Excel and VBASolidWorks Design Automation Using the SolidWorks API, Microsoft Excel and VBA
SolidWorks Design Automation Using the SolidWorks API, Microsoft Excel and VBARazorleaf Corporation
 

Andere mochten auch (17)

Vba Class Level 1
Vba Class Level 1Vba Class Level 1
Vba Class Level 1
 
Excel vba macro programing
Excel vba macro programingExcel vba macro programing
Excel vba macro programing
 
Vba Excel Level 2
Vba Excel Level 2Vba Excel Level 2
Vba Excel Level 2
 
Advanced Microsoft Excel
Advanced Microsoft ExcelAdvanced Microsoft Excel
Advanced Microsoft Excel
 
Excel ch10
Excel ch10Excel ch10
Excel ch10
 
985 paper presentation -banff 2015
985 paper presentation -banff 2015985 paper presentation -banff 2015
985 paper presentation -banff 2015
 
Service tax procedure in india aces for all assesses
Service tax procedure in india   aces for all assessesService tax procedure in india   aces for all assesses
Service tax procedure in india aces for all assesses
 
新觀念的VB6教本ch12
新觀念的VB6教本ch12新觀念的VB6教本ch12
新觀念的VB6教本ch12
 
新觀念的VB6教本ch11
新觀念的VB6教本ch11新觀念的VB6教本ch11
新觀念的VB6教本ch11
 
新觀念的VB6教本ch13
新觀念的VB6教本ch13新觀念的VB6教本ch13
新觀念的VB6教本ch13
 
新觀念的VB6教本ch04
新觀念的VB6教本ch04新觀念的VB6教本ch04
新觀念的VB6教本ch04
 
Demystifying Mergers and Acquisition
Demystifying Mergers and AcquisitionDemystifying Mergers and Acquisition
Demystifying Mergers and Acquisition
 
Management productivity tools1
Management productivity tools1Management productivity tools1
Management productivity tools1
 
新觀念的VB6教本ch03
新觀念的VB6教本ch03新觀念的VB6教本ch03
新觀念的VB6教本ch03
 
新觀念的VB6教本ch02
新觀念的VB6教本ch02新觀念的VB6教本ch02
新觀念的VB6教本ch02
 
新觀念的VB6教本ch08
新觀念的VB6教本ch08新觀念的VB6教本ch08
新觀念的VB6教本ch08
 
SolidWorks Design Automation Using the SolidWorks API, Microsoft Excel and VBA
SolidWorks Design Automation Using the SolidWorks API, Microsoft Excel and VBASolidWorks Design Automation Using the SolidWorks API, Microsoft Excel and VBA
SolidWorks Design Automation Using the SolidWorks API, Microsoft Excel and VBA
 

Ähnlich wie Excel VBA Macros for Automation and Efficiency

Online Advance Excel & VBA Training in India
 Online Advance Excel & VBA Training in India Online Advance Excel & VBA Training in India
Online Advance Excel & VBA Training in Indiaibinstitute0
 
Learn VBA Training & Advance Excel Courses in Delhi
Learn VBA Training & Advance Excel Courses in DelhiLearn VBA Training & Advance Excel Courses in Delhi
Learn VBA Training & Advance Excel Courses in Delhiibinstitute0
 
Getting started with CATIA V5 Macros
Getting started with CATIA V5 MacrosGetting started with CATIA V5 Macros
Getting started with CATIA V5 MacrosEmmett Ross
 
200 Mega eBook Collection- http://bit.ly/3WEZuYJ
200 Mega eBook Collection- http://bit.ly/3WEZuYJ200 Mega eBook Collection- http://bit.ly/3WEZuYJ
200 Mega eBook Collection- http://bit.ly/3WEZuYJDannySingh23
 
Advance excel training in pune ppt.
Advance excel training in pune ppt.Advance excel training in pune ppt.
Advance excel training in pune ppt.sambhajimeher
 
Creating A User‑Defined Function In Excel Using Vba
Creating A User‑Defined Function In Excel Using VbaCreating A User‑Defined Function In Excel Using Vba
Creating A User‑Defined Function In Excel Using VbaChester Tugwell
 
Excel basics for everyday use part two
Excel basics for everyday use part twoExcel basics for everyday use part two
Excel basics for everyday use part twoKevin McLogan
 
Getting Started with Excel Macros – Day #1
Getting Started with Excel Macros – Day #1Getting Started with Excel Macros – Day #1
Getting Started with Excel Macros – Day #1Tariq Al-Basha
 
Excel Macros and VBA Programming Training Bangalore:
Excel Macros and VBA Programming Training Bangalore:Excel Macros and VBA Programming Training Bangalore:
Excel Macros and VBA Programming Training Bangalore:IGEEKS TECHNOLOGIES
 
Luke Cushanick Admin Tips and Tricks for Salesforce Trailblazer Community Chr...
Luke Cushanick Admin Tips and Tricks for Salesforce Trailblazer Community Chr...Luke Cushanick Admin Tips and Tricks for Salesforce Trailblazer Community Chr...
Luke Cushanick Admin Tips and Tricks for Salesforce Trailblazer Community Chr...Anna Loughnan Colquhoun
 
Excel VBA.pptx
Excel VBA.pptxExcel VBA.pptx
Excel VBA.pptxGiyaShefin
 
Unit ii introduction to vba
Unit ii introduction to vbaUnit ii introduction to vba
Unit ii introduction to vbaDhana malar
 

Ähnlich wie Excel VBA Macros for Automation and Efficiency (20)

Online Advance Excel & VBA Training in India
 Online Advance Excel & VBA Training in India Online Advance Excel & VBA Training in India
Online Advance Excel & VBA Training in India
 
Learn VBA Training & Advance Excel Courses in Delhi
Learn VBA Training & Advance Excel Courses in DelhiLearn VBA Training & Advance Excel Courses in Delhi
Learn VBA Training & Advance Excel Courses in Delhi
 
Getting started with CATIA V5 Macros
Getting started with CATIA V5 MacrosGetting started with CATIA V5 Macros
Getting started with CATIA V5 Macros
 
200 Mega eBook Collection- http://bit.ly/3WEZuYJ
200 Mega eBook Collection- http://bit.ly/3WEZuYJ200 Mega eBook Collection- http://bit.ly/3WEZuYJ
200 Mega eBook Collection- http://bit.ly/3WEZuYJ
 
Vba part 1
Vba part 1Vba part 1
Vba part 1
 
Vba Class Level 3
Vba Class Level 3Vba Class Level 3
Vba Class Level 3
 
Advance excel training in pune ppt.
Advance excel training in pune ppt.Advance excel training in pune ppt.
Advance excel training in pune ppt.
 
Vba 2 (students copy)
Vba 2 (students copy)Vba 2 (students copy)
Vba 2 (students copy)
 
ExcelMacros.pptx
ExcelMacros.pptxExcelMacros.pptx
ExcelMacros.pptx
 
Creating A User‑Defined Function In Excel Using Vba
Creating A User‑Defined Function In Excel Using VbaCreating A User‑Defined Function In Excel Using Vba
Creating A User‑Defined Function In Excel Using Vba
 
Excel basics for everyday use part two
Excel basics for everyday use part twoExcel basics for everyday use part two
Excel basics for everyday use part two
 
ExcelMacros.pptx
ExcelMacros.pptxExcelMacros.pptx
ExcelMacros.pptx
 
Getting Started with Excel Macros – Day #1
Getting Started with Excel Macros – Day #1Getting Started with Excel Macros – Day #1
Getting Started with Excel Macros – Day #1
 
Automating SolidWorks with Excel
Automating SolidWorks with ExcelAutomating SolidWorks with Excel
Automating SolidWorks with Excel
 
Excel Macros and VBA Programming Training Bangalore:
Excel Macros and VBA Programming Training Bangalore:Excel Macros and VBA Programming Training Bangalore:
Excel Macros and VBA Programming Training Bangalore:
 
VBA.pptx
VBA.pptxVBA.pptx
VBA.pptx
 
Luke Cushanick Admin Tips and Tricks for Salesforce Trailblazer Community Chr...
Luke Cushanick Admin Tips and Tricks for Salesforce Trailblazer Community Chr...Luke Cushanick Admin Tips and Tricks for Salesforce Trailblazer Community Chr...
Luke Cushanick Admin Tips and Tricks for Salesforce Trailblazer Community Chr...
 
Excel vba
Excel vbaExcel vba
Excel vba
 
Excel VBA.pptx
Excel VBA.pptxExcel VBA.pptx
Excel VBA.pptx
 
Unit ii introduction to vba
Unit ii introduction to vbaUnit ii introduction to vba
Unit ii introduction to vba
 

Mehr von AbhisheK Kumar Rajoria

Future Perfect-Metaverse in marketing opens a new era of innovation_Final.doc
Future Perfect-Metaverse in marketing opens a new era of innovation_Final.docFuture Perfect-Metaverse in marketing opens a new era of innovation_Final.doc
Future Perfect-Metaverse in marketing opens a new era of innovation_Final.docAbhisheK Kumar Rajoria
 
Creating Value in Business with Innovation .pptx
Creating Value in Business with Innovation .pptxCreating Value in Business with Innovation .pptx
Creating Value in Business with Innovation .pptxAbhisheK Kumar Rajoria
 
New normal digital insights and recommendations
New normal digital insights and recommendationsNew normal digital insights and recommendations
New normal digital insights and recommendationsAbhisheK Kumar Rajoria
 
New Normal Recommendations For Brands to Help in Marketing
New Normal Recommendations For Brands to Help in MarketingNew Normal Recommendations For Brands to Help in Marketing
New Normal Recommendations For Brands to Help in MarketingAbhisheK Kumar Rajoria
 
Market analysis and the buying behavior of buyers of paper industry
Market analysis and the buying behavior of  buyers of paper industryMarket analysis and the buying behavior of  buyers of paper industry
Market analysis and the buying behavior of buyers of paper industryAbhisheK Kumar Rajoria
 
HR project on recruitment, selection of financial advisor and bancassurance
HR project on recruitment, selection of financial advisor and bancassuranceHR project on recruitment, selection of financial advisor and bancassurance
HR project on recruitment, selection of financial advisor and bancassuranceAbhisheK Kumar Rajoria
 
Analysis of-consumer-perception-on-dabur-honey
Analysis of-consumer-perception-on-dabur-honeyAnalysis of-consumer-perception-on-dabur-honey
Analysis of-consumer-perception-on-dabur-honeyAbhisheK Kumar Rajoria
 

Mehr von AbhisheK Kumar Rajoria (11)

Future Perfect-Metaverse in marketing opens a new era of innovation_Final.doc
Future Perfect-Metaverse in marketing opens a new era of innovation_Final.docFuture Perfect-Metaverse in marketing opens a new era of innovation_Final.doc
Future Perfect-Metaverse in marketing opens a new era of innovation_Final.doc
 
mordern marketing metrics.pptx
mordern marketing metrics.pptxmordern marketing metrics.pptx
mordern marketing metrics.pptx
 
Digital Marketing.pptx
Digital Marketing.pptxDigital Marketing.pptx
Digital Marketing.pptx
 
Creating Value in Business with Innovation .pptx
Creating Value in Business with Innovation .pptxCreating Value in Business with Innovation .pptx
Creating Value in Business with Innovation .pptx
 
New normal digital insights and recommendations
New normal digital insights and recommendationsNew normal digital insights and recommendations
New normal digital insights and recommendations
 
New Normal Recommendations For Brands to Help in Marketing
New Normal Recommendations For Brands to Help in MarketingNew Normal Recommendations For Brands to Help in Marketing
New Normal Recommendations For Brands to Help in Marketing
 
Market analysis and the buying behavior of buyers of paper industry
Market analysis and the buying behavior of  buyers of paper industryMarket analysis and the buying behavior of  buyers of paper industry
Market analysis and the buying behavior of buyers of paper industry
 
HR project on recruitment, selection of financial advisor and bancassurance
HR project on recruitment, selection of financial advisor and bancassuranceHR project on recruitment, selection of financial advisor and bancassurance
HR project on recruitment, selection of financial advisor and bancassurance
 
E commerce presentation
E commerce presentationE commerce presentation
E commerce presentation
 
Analysis of-consumer-perception-on-dabur-honey
Analysis of-consumer-perception-on-dabur-honeyAnalysis of-consumer-perception-on-dabur-honey
Analysis of-consumer-perception-on-dabur-honey
 
Tools and analyses in google adwords
Tools and analyses in google adwordsTools and analyses in google adwords
Tools and analyses in google adwords
 

Kürzlich hochgeladen

HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptxMusic 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptxleah joy valeriano
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 

Kürzlich hochgeladen (20)

HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptxMusic 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
Music 9 - 4th quarter - Vocal Music of the Romantic Period.pptx
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 

Excel VBA Macros for Automation and Efficiency

  • 2. • Excel is object based model… • Objects include things such as application, workbook, worksheet, cells • Each object has properties • Color, border, value, name Macros execute tasks according to instructions. Macros do not think… • Everything you do can be expressed in code (instructions); it is stored the same way. • Each time you do anything in Excel the same action can be expressed in code. • You interact with excel through an interface that makes the code easier to understand/intuit. • Choosing the “sheet1” sheet is expressed as; Sheets(“sheet1”).Select
  • 3. • It saves time giving you more time to work on higher level tasks • VBA can do things more quickly than you can. • It standardizes processes, eliminates error due to deviation from instructions • It will do the exact same thing each time it runs
  • 4. • When you are doing a routine task that you can write VERY good instructions for doing, you can likely automate that task by using VBA. • We won‟t use it when abstract thinking or problem solving is a necessary component of the task or when there are any new variables present in our current task.
  • 5. • Developer tab – first you show get access • Record a macro button – in Developer tab • Alt + F11 show the VBE; Visual Basic Editor • Tour of VBA code area • Project tree, object properties, space for code
  • 6. • Recording • Button • Naming – no spaces; use underscores or caps • Save in a Workbook • Save in Personal workbook • What is personal workbook • How to open it for the first time • Once you save a macro it opens each time you open Excel • Always hidden. • If you unhide PW and close excel, PW will close! • To re-open; C:Documents and SettingsusernameApplication DataMicrosoftExcelXLSTART – Application Data file is hidden! • How to call the macro – from Developer tab • Save workbook as .xlsm or you will lose your work!
  • 7. Standard R1C1 =A1+1 =RC[-1]+1 =$A$1+1 =R1C1+1 =$A1+1 =RC1+1 =A$1+1 =R1C[-1]+1 =Sum(A1:A10) =Sum(RC[-1]:R[9]C[-1]) =Sum($A$1:$A$10) =Sum(R1C1:R10C1) • Module subroutines • Show what recording does • Walk through example • Show excess that gets recorded and then how to spot and clean • R1C1 syntax vs. Regular • What is R1C1? • What does R1C1 syntax look like and how to convert? (formula in B1)
  • 8. • Break mode • When running code produces error you get break mode to fix error and prevent code from continuing or application running. • Sometimes nothing works! Maybe you‟re in break mode? • How to tell and how to tell (in title and yellow highlighting) • How to get out of break mode. • Notes in VBA code • How to write notes “ „ “ • Why to write them • Break code into chunks by function • Record sections of code if you don‟t know syntax
  • 9. • How to run code from VBE • Call Macro from Excel, F5 in VBA, or “run” from drop-down • How to break code if it keeps going • Show from example • How to create dynamic row length (create example where we see the problem to illustrate problem solving tactic) • Declaring variables using Dim xxx as xxx • Substitute variable for specific reference in code • Code upon a user action In VBA Editor select workbook object • Change left drop-down box to “workbook” • Change right drop-down box to desired action • Place code within the newly create subroutine boundaries
  • 10. • Loops • For Syntax and example • If Syntax and example • Do While Syntax and example • Example of code/program • Buttons and things • Where to insert buttons • How to assign code to buttons • Userforms • Awesome but code gets more complex • Don‟t forget objects have values – radio button.value can be true or false
  • 11. • Macros run from wherever you call them if you call them on the wrong sheet the result can be really bad • Use Sheets(“sheetname”).Select to make sure it always goes to the right sheet before you call it • Usage of message boxes to check code – msgbox “stop” • Problem: with filters being off and on and errors – they need to be correct or you‟ll get errors • Problem: with sheets being hidden and referencing them for actions • Error handling • If it is possible that your code will generate an error you don‟t want your code to stop running. Need to tell it to do so b/c by default it stops. 2 methods: • On Error Goto Next • On Error Goto 0
  • 12. • Syntax in VBA and Excel is not the same…. Of course • Use msgboxes to help see if your code is right • More quotes are needed. • Create a UI with hiding sheets • Create codes that show and hide sheets so that when an action is taken you go to a different part of a workbook. This turns a workbook into an application. • Save before you run, extremely hard to undo macros • The best code never uses the “select” code! Each time this happens it slows down the code. See if you can find ways to only use VBA. • Example: Paste special values formula can be written as „Range(“A3”).Value = Range(“A3”).Value‟