SlideShare a Scribd company logo
3
Most read
8
Most read
10
Most read
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‟
Learn Excel Macro

More Related Content

PDF
Getting started with Microsoft Excel Macros
PPTX
Data Visualization
PPTX
Data Analysis with MS Excel.pptx
PPTX
Financial Statement
PPTX
Pivot table
PPT
Networking, Relationship Building and Social Media
PPTX
Stat 2153 Stochastic Process and Markov chain
Getting started with Microsoft Excel Macros
Data Visualization
Data Analysis with MS Excel.pptx
Financial Statement
Pivot table
Networking, Relationship Building and Social Media
Stat 2153 Stochastic Process and Markov chain

What's hot (20)

PPTX
Microsoft Excel - Macros
PPT
Using macros in microsoft excel part 1
PDF
Excel Macro Magic
PPTX
Vba introduction
PPTX
Excel-VBA
PPTX
A Quick Simple MS Excel Macro
PPT
MACROS excel
PPTX
Introduction to Excel VBA/Macros
PPTX
An introduction to vba and macros
PPT
VBA - Macro For Ms.Excel
PPTX
Excel macro
PPTX
PPTX
E learning excel vba programming lesson 3
PPTX
Vba part 1
PDF
Excel VBA programming basics
PPTX
Basic Ms excel
PPT
Excel Training
PPTX
Excel lesson01
PPTX
Excel for beginner
Microsoft Excel - Macros
Using macros in microsoft excel part 1
Excel Macro Magic
Vba introduction
Excel-VBA
A Quick Simple MS Excel Macro
MACROS excel
Introduction to Excel VBA/Macros
An introduction to vba and macros
VBA - Macro For Ms.Excel
Excel macro
E learning excel vba programming lesson 3
Vba part 1
Excel VBA programming basics
Basic Ms excel
Excel Training
Excel lesson01
Excel for beginner
Ad

Viewers also liked (18)

PPTX
Introduction To Excel 2007 Macros
PPTX
Vba Class Level 1
PDF
Excel vba macro programing
PPTX
Vba Excel Level 2
PDF
Advanced Microsoft Excel
PPTX
Excel ch10
PPTX
985 paper presentation -banff 2015
PPSX
Service tax procedure in india aces for all assesses
PPT
新觀念的VB6教本ch12
PPT
新觀念的VB6教本ch11
PPT
新觀念的VB6教本ch13
PPT
新觀念的VB6教本ch04
PPTX
Demystifying Mergers and Acquisition
PPTX
Management productivity tools1
PPT
新觀念的VB6教本ch03
PPT
新觀念的VB6教本ch02
PPT
新觀念的VB6教本ch08
PPTX
SolidWorks Design Automation Using the SolidWorks API, Microsoft Excel and VBA
Introduction To Excel 2007 Macros
Vba Class Level 1
Excel vba macro programing
Vba Excel Level 2
Advanced Microsoft Excel
Excel ch10
985 paper presentation -banff 2015
Service tax procedure in india aces for all assesses
新觀念的VB6教本ch12
新觀念的VB6教本ch11
新觀念的VB6教本ch13
新觀念的VB6教本ch04
Demystifying Mergers and Acquisition
Management productivity tools1
新觀念的VB6教本ch03
新觀念的VB6教本ch02
新觀念的VB6教本ch08
SolidWorks Design Automation Using the SolidWorks API, Microsoft Excel and VBA
Ad

Similar to Learn Excel Macro (20)

PDF
Online Advance Excel & VBA Training in India
PPTX
Learn VBA Training & Advance Excel Courses in Delhi
PDF
Getting started with CATIA V5 Macros
PDF
200 Mega eBook Collection- http://bit.ly/3WEZuYJ
PDF
Vba part 1
PPTX
Vba Class Level 3
PPTX
Advance excel training in pune ppt.
PDF
40 Ready to Use Excel VBA and Macros (Mac Guru).pdf
PPTX
Excel Macros automate tasks you do often.
PDF
Vba 2 (students copy)
PPTX
ExcelMacros.pptx
PPT
Creating A User‑Defined Function In Excel Using Vba
PPTX
Excel basics for everyday use part two
PPTX
ExcelMacros.pptx
PPTX
Automating SolidWorks with Excel
PDF
Excel Macros and VBA Programming Training Bangalore:
PPTX
PPTX
Luke Cushanick Admin Tips and Tricks for Salesforce Trailblazer Community Chr...
DOCX
Excel vba
PPTX
ExcelMacrosAndVBA-PP.pptx rqererrwtwtwtwe
Online Advance Excel & VBA Training in India
Learn VBA Training & Advance Excel Courses in Delhi
Getting started with CATIA V5 Macros
200 Mega eBook Collection- http://bit.ly/3WEZuYJ
Vba part 1
Vba Class Level 3
Advance excel training in pune ppt.
40 Ready to Use Excel VBA and Macros (Mac Guru).pdf
Excel Macros automate tasks you do often.
Vba 2 (students copy)
ExcelMacros.pptx
Creating A User‑Defined Function In Excel Using Vba
Excel basics for everyday use part two
ExcelMacros.pptx
Automating SolidWorks with Excel
Excel Macros and VBA Programming Training Bangalore:
Luke Cushanick Admin Tips and Tricks for Salesforce Trailblazer Community Chr...
Excel vba
ExcelMacrosAndVBA-PP.pptx rqererrwtwtwtwe

More from AbhisheK Kumar Rajoria (12)

DOCX
Tune into Data-Driven Campaigns on Connected TV.docx
DOC
Future Perfect-Metaverse in marketing opens a new era of innovation_Final.doc
PPTX
mordern marketing metrics.pptx
PPTX
Digital Marketing.pptx
PPTX
Creating Value in Business with Innovation .pptx
PPTX
New normal digital insights and recommendations
PPTX
New Normal Recommendations For Brands to Help in Marketing
PDF
Market analysis and the buying behavior of buyers of paper industry
DOCX
HR project on recruitment, selection of financial advisor and bancassurance
PPTX
E commerce presentation
DOC
Analysis of-consumer-perception-on-dabur-honey
PPTX
Tools and analyses in google adwords
Tune into Data-Driven Campaigns on Connected TV.docx
Future Perfect-Metaverse in marketing opens a new era of innovation_Final.doc
mordern marketing metrics.pptx
Digital Marketing.pptx
Creating Value in Business with Innovation .pptx
New normal digital insights and recommendations
New Normal Recommendations For Brands to Help in Marketing
Market analysis and the buying behavior of buyers of paper industry
HR project on recruitment, selection of financial advisor and bancassurance
E commerce presentation
Analysis of-consumer-perception-on-dabur-honey
Tools and analyses in google adwords

Recently uploaded (20)

PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Pharma ospi slides which help in ospi learning
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Basic Mud Logging Guide for educational purpose
PDF
Computing-Curriculum for Schools in Ghana
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Classroom Observation Tools for Teachers
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Lesson notes of climatology university.
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Microbial disease of the cardiovascular and lymphatic systems
Pharma ospi slides which help in ospi learning
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Basic Mud Logging Guide for educational purpose
Computing-Curriculum for Schools in Ghana
O7-L3 Supply Chain Operations - ICLT Program
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
human mycosis Human fungal infections are called human mycosis..pptx
Microbial diseases, their pathogenesis and prophylaxis
Classroom Observation Tools for Teachers
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
102 student loan defaulters named and shamed – Is someone you know on the list?
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Final Presentation General Medicine 03-08-2024.pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Lesson notes of climatology university.
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...

Learn Excel Macro

  • 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‟