SlideShare a Scribd company logo
1 of 49
Introduction to
Excel VBA/Macros:
Some Examples on Logistics
and Supply Chain Management
Dr. Kang Mun Arturo Tan
Assistant Professor
Logistics and Supply Chain Management
Data Analytics
Yanbu University College
General Outline
A_Why does Excel VBA matter?
B_ What is VBA?
C_ How do we start with VBA?
D_ Recording some macros.
E_ Running the macros.
F_ Functions and Sub_Routines.
G_ The User Form.
slideNo3
Thanks
COVER
A_ Why does Excel VBA Matter
A_ Why does VBA Excel Matter
Excel is widely used across the world.
A_ Why does VBA Excel Matter
Excel is widely used across the world.
Many corporate data, both structured
and unstructured are in Excel.
A_ Why does VBA Excel Matter
Excel is widely used across the world.
Many corporate data, both structured
and unstructured are in Excel.
Processing of data residing in Excel
has become a routine work for many
professionals.
A_ Why does VBA Excel Matter
Excel is widely used across the world.
Many corporate data, both structured
and unstructured are in Excel.
Processing of data residing in Excel
has become a routine work for many
professionals.
Automating this work could be an added
advantage for the students who are
entering the workforce.
BackToTOC
B_ What is VBA
VBA stands for Visual Basic for
Application.
It is very similar to Visual Basic
in form and structure.
It works with Excel, Word, Access,
Powerpoint and Outlook.
Theory:
For Excel, it deals with Excel Object Model.
Object, intuitively, is like an XLNoid – a robot.
Method is a call to action.
Property is a data stored in that data basket, with
the XLNoid constantly checking, and deciding
if an action is needed.
Theory: Overall Structure
Application Project
Worksheets Modules User_Form
Macro Window
Buttons
Call Form
Read/Write Data
For Excel, it deals with Excel Object Model.
Application
Workbook
Worksheets
Range
Cell
BackToTOC
BackTo_B
C_ How do we start with Excel VBA
Check for Activation
Demo for Start Up
Tan_C_Slide
C_ How do we start with Excel VBA
C_ How do we start with Excel VBA
C_ How do we start with Excel VBA
C_ How do we start with Excel VBA
C_ How do we start with Excel VBA
BackToTOC
BackToC
D_ Recording some VBA Macros Show
Recording
Process
Tan_D_Slide
D_ Recording some VBA Macros
D_ Recording some VBA Macros
D_ Recording some VBA Macros
D_ Recording some VBA Macros
D_ Recording some VBA Macros
D_ Recording some VBA Macros
Overall code
D_ Recording some VBA Macros
R[ Up/Down CellDistance] C[Left/Right CellDistance]
Focusing on the formula:
“R[-4] C + R[-3] C - R[-2] C “
D_ Recording some VBA Macros
ActiveCell.Offset( Up/Down CellStep, Left/Right CellStep)
Relative Recording
D_ Recording some VBA Macros
Calling both MyMacro01 and MyMacro02
D_ Recording some VBA Macros
D_ Recording some VBA Macros
D_ Recording some VBA Macros
Clearing the area
BackToTOC
BackToD
E_ Running the macros
Alt+F8
Analyzing
the recorded
macros
Tan_E_Slide
E_ Running the macros
E_ Running the macros
E_ Running the macros
BackToTOC
BackToE
F_ Functions and Sub Routines
Cell
To Fill Up a Cell with a Value
To Fill Up a Cell with a Formula
To Read a Cell’s Value
F_ Functions and Sub Routines
BegInvy + Receipts – Issuances
= EndInvy
As a function:
As a subprocedure:
Demo for
Coding
of
Sub proc
and
Functions
Tan_FA_Slide
F_ Functions and Sub Routines
EoQ = Sqrt (2 DS / H )
D = Demand for a Year
S = Cost for each Ordering
H = Holding Cost per Item per Year
Demo for Preparing
A report
BackToTOC
BackToF
Tan_FA_Slide
Fc1_ General Example
Option Explicit
Sub MyMacroGetMax()
Dim q As Variant
Dim x(100) As Integer
Dim i As Integer, nPtr As Integer
Dim Start As Integer, Last As Integer, Num As Integer
Dim AssumedHeaviest, Heaviest As Integer
' Defining the array
q = Array(7, 2, 3, 20, 15, 6, 35, 12, 9, 5, 18, 23, _
9, 16, 22, 10)
Demo for Straight Coding
Tan_FC_Slide
Fc2_ General Example
Start = LBound(q)
MsgBox "StartBoxNo is " & Start
Last = UBound(q)
MsgBox "LastBoxNo is " & Last
Num = Last - Start + 1
MsgBox "BoxCount is " & Num
' = = == = = = = = =
' transferring the content of container q to container x.
‘ container x is a temporary place for comparison.
' ========= = = = = =
For i = Start To Last
x(i) = q(i)
Next i
' = = = = = = = = = = =
Fc3_ General Example
' = =
' assume the first box to be the heaviest.
' = = =
AssumedHeaviest = x(Start) ‘// Start means the first box
' = = = =
For nPtr = Start + 1 To Last ‘// Start+1 means the second box
If x(nPtr) > AssumedHeaviest Then
AssumedHeaviest = x(nPtr)
End If
Next nPtr
Heaviest = AssumedHeaviest
MsgBox "Heaviest is " & Heaviest
End Sub
BackToTOC
BackToFc
G_ UserForm Example
Call Demo G
Tan_G_Slide
G_ UserForm Example
G_ UserForm Example
G_ UserForm Example
G_ UserForm Example
G_ UserForm Example
G_ UserForm Example
BackToTOC
BackToG
H_ Overall Structure
Application Project
Worksheets Modules User_Form
Macro Window
Buttons
Call Form
Read/Write Data
BackToTOC
Thank You!!!!!
BackToTOC

More Related Content

What's hot

Using macros in microsoft excel part 1
Using macros in microsoft excel   part 1Using macros in microsoft excel   part 1
Using macros in microsoft excel part 1Er. Nawaraj Bhandari
 
Introduction To Excel 2007 Macros
Introduction To Excel 2007 MacrosIntroduction To Excel 2007 Macros
Introduction To Excel 2007 MacrosExcel
 
Business KPI Dashboard Showing Lead To Opportunity Ratio
Business KPI Dashboard Showing Lead To Opportunity RatioBusiness KPI Dashboard Showing Lead To Opportunity Ratio
Business KPI Dashboard Showing Lead To Opportunity RatioSlideTeam
 
10 Excel Formulas that will help you in any Job
10 Excel Formulas that will help you in any Job10 Excel Formulas that will help you in any Job
10 Excel Formulas that will help you in any JobHitesh Biyani
 
Vlookup - an introduction
Vlookup - an introductionVlookup - an introduction
Vlookup - an introductionvvmenon22
 
Excel 2010
Excel 2010Excel 2010
Excel 2010nhumar
 
Introduction to Microsoft Excel basics | Excel Intro | Excel | Excel for star...
Introduction to Microsoft Excel basics | Excel Intro | Excel | Excel for star...Introduction to Microsoft Excel basics | Excel Intro | Excel | Excel for star...
Introduction to Microsoft Excel basics | Excel Intro | Excel | Excel for star...Corp-sKool
 
Process Scope Powerpoint Template
Process Scope Powerpoint TemplateProcess Scope Powerpoint Template
Process Scope Powerpoint TemplateSlideTeam
 

What's hot (20)

Using macros in microsoft excel part 1
Using macros in microsoft excel   part 1Using macros in microsoft excel   part 1
Using macros in microsoft excel part 1
 
Excel Macro Magic
Excel Macro MagicExcel Macro Magic
Excel Macro Magic
 
Learn Excel Macro
Learn Excel Macro  Learn Excel Macro
Learn Excel Macro
 
VBA - Macro For Ms.Excel
VBA - Macro For Ms.ExcelVBA - Macro For Ms.Excel
VBA - Macro For Ms.Excel
 
Excel macro
Excel macroExcel macro
Excel macro
 
Excel-VBA
Excel-VBAExcel-VBA
Excel-VBA
 
Vba
Vba Vba
Vba
 
Microsoft Excel Tutorial
Microsoft Excel TutorialMicrosoft Excel Tutorial
Microsoft Excel Tutorial
 
Introduction To Excel 2007 Macros
Introduction To Excel 2007 MacrosIntroduction To Excel 2007 Macros
Introduction To Excel 2007 Macros
 
An introduction to vba and macros
An introduction to vba and macrosAn introduction to vba and macros
An introduction to vba and macros
 
Business KPI Dashboard Showing Lead To Opportunity Ratio
Business KPI Dashboard Showing Lead To Opportunity RatioBusiness KPI Dashboard Showing Lead To Opportunity Ratio
Business KPI Dashboard Showing Lead To Opportunity Ratio
 
10 Excel Formulas that will help you in any Job
10 Excel Formulas that will help you in any Job10 Excel Formulas that will help you in any Job
10 Excel Formulas that will help you in any Job
 
Excel training
Excel trainingExcel training
Excel training
 
اكسل
اكسلاكسل
اكسل
 
Vlookup - an introduction
Vlookup - an introductionVlookup - an introduction
Vlookup - an introduction
 
Excel formula
Excel formulaExcel formula
Excel formula
 
Excel 2010
Excel 2010Excel 2010
Excel 2010
 
Microsoft Excel - Macros
Microsoft Excel - MacrosMicrosoft Excel - Macros
Microsoft Excel - Macros
 
Introduction to Microsoft Excel basics | Excel Intro | Excel | Excel for star...
Introduction to Microsoft Excel basics | Excel Intro | Excel | Excel for star...Introduction to Microsoft Excel basics | Excel Intro | Excel | Excel for star...
Introduction to Microsoft Excel basics | Excel Intro | Excel | Excel for star...
 
Process Scope Powerpoint Template
Process Scope Powerpoint TemplateProcess Scope Powerpoint Template
Process Scope Powerpoint Template
 

Similar to Introduction to Excel VBA/Macros

Bt0082, visual basic
Bt0082, visual basicBt0082, visual basic
Bt0082, visual basicsmumbahelp
 
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesChoose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesCHOOSE
 
Object Oriented Programming in Matlab
Object Oriented Programming in Matlab Object Oriented Programming in Matlab
Object Oriented Programming in Matlab AlbanLevy
 
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
 
Spreadsheet Analytical Tools
Spreadsheet Analytical ToolsSpreadsheet Analytical Tools
Spreadsheet Analytical ToolsJoselito Perez
 
Advanced Microsoft Excel Training
Advanced Microsoft Excel TrainingAdvanced Microsoft Excel Training
Advanced Microsoft Excel TrainingSpoc learn
 
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
 
Chapter 16-spreadsheet1 questions and answer
Chapter 16-spreadsheet1  questions and answerChapter 16-spreadsheet1  questions and answer
Chapter 16-spreadsheet1 questions and answerRaajTech
 
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptSourabhPal46
 
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptMard Geer
 
Cmps 260, fall 2021 programming assignment #3 (125 points)
Cmps 260, fall 2021 programming assignment #3 (125 points)Cmps 260, fall 2021 programming assignment #3 (125 points)
Cmps 260, fall 2021 programming assignment #3 (125 points)mehek4
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9google
 
The Java Fx Platform – A Java Developer’S Guide
The Java Fx Platform – A Java Developer’S GuideThe Java Fx Platform – A Java Developer’S Guide
The Java Fx Platform – A Java Developer’S GuideStephen Chin
 
"Optimization of a .NET application- is it simple ! / ?", Yevhen Tatarynov
"Optimization of a .NET application- is it simple ! / ?",  Yevhen Tatarynov"Optimization of a .NET application- is it simple ! / ?",  Yevhen Tatarynov
"Optimization of a .NET application- is it simple ! / ?", Yevhen TatarynovFwdays
 
2. data types, variables and operators
2. data types, variables and operators2. data types, variables and operators
2. data types, variables and operatorsPhD Research Scholar
 
Vba and macro creation (using excel)
Vba and macro creation (using excel)Vba and macro creation (using excel)
Vba and macro creation (using excel)Javier Morales Cauna
 

Similar to Introduction to Excel VBA/Macros (20)

Unit 3
Unit 3Unit 3
Unit 3
 
Bt0082, visual basic
Bt0082, visual basicBt0082, visual basic
Bt0082, visual basic
 
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesChoose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
 
Object Oriented Programming in Matlab
Object Oriented Programming in Matlab Object Oriented Programming in Matlab
Object Oriented Programming in Matlab
 
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
 
Spreadsheet Analytical Tools
Spreadsheet Analytical ToolsSpreadsheet Analytical Tools
Spreadsheet Analytical Tools
 
Advanced Microsoft Excel Training
Advanced Microsoft Excel TrainingAdvanced Microsoft Excel Training
Advanced Microsoft Excel Training
 
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
 
Matopt
MatoptMatopt
Matopt
 
70433 Dumps DB
70433 Dumps DB70433 Dumps DB
70433 Dumps DB
 
Chapter 16-spreadsheet1 questions and answer
Chapter 16-spreadsheet1  questions and answerChapter 16-spreadsheet1  questions and answer
Chapter 16-spreadsheet1 questions and answer
 
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.ppt
 
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.ppt
 
Cmps 260, fall 2021 programming assignment #3 (125 points)
Cmps 260, fall 2021 programming assignment #3 (125 points)Cmps 260, fall 2021 programming assignment #3 (125 points)
Cmps 260, fall 2021 programming assignment #3 (125 points)
 
pm1
pm1pm1
pm1
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9
 
The Java Fx Platform – A Java Developer’S Guide
The Java Fx Platform – A Java Developer’S GuideThe Java Fx Platform – A Java Developer’S Guide
The Java Fx Platform – A Java Developer’S Guide
 
"Optimization of a .NET application- is it simple ! / ?", Yevhen Tatarynov
"Optimization of a .NET application- is it simple ! / ?",  Yevhen Tatarynov"Optimization of a .NET application- is it simple ! / ?",  Yevhen Tatarynov
"Optimization of a .NET application- is it simple ! / ?", Yevhen Tatarynov
 
2. data types, variables and operators
2. data types, variables and operators2. data types, variables and operators
2. data types, variables and operators
 
Vba and macro creation (using excel)
Vba and macro creation (using excel)Vba and macro creation (using excel)
Vba and macro creation (using excel)
 

More from arttan2001

Dax Power Pivot: Introductory Level
Dax Power Pivot: Introductory Level Dax Power Pivot: Introductory Level
Dax Power Pivot: Introductory Level arttan2001
 
Uber210 slide share
Uber210 slide shareUber210 slide share
Uber210 slide sharearttan2001
 
Logistics Systems Design for the Yangtze River Delta Region
Logistics Systems Design for the Yangtze River Delta RegionLogistics Systems Design for the Yangtze River Delta Region
Logistics Systems Design for the Yangtze River Delta Regionarttan2001
 
Summarizing Siegel's Predictive Analytics
Summarizing Siegel's Predictive Analytics Summarizing Siegel's Predictive Analytics
Summarizing Siegel's Predictive Analytics arttan2001
 
Linux for Education
Linux for EducationLinux for Education
Linux for Educationarttan2001
 
R and Rcmdr Statistical Software
R and Rcmdr Statistical SoftwareR and Rcmdr Statistical Software
R and Rcmdr Statistical Softwarearttan2001
 

More from arttan2001 (7)

Dax Power Pivot: Introductory Level
Dax Power Pivot: Introductory Level Dax Power Pivot: Introductory Level
Dax Power Pivot: Introductory Level
 
Uber210 slide share
Uber210 slide shareUber210 slide share
Uber210 slide share
 
Logistics Systems Design for the Yangtze River Delta Region
Logistics Systems Design for the Yangtze River Delta RegionLogistics Systems Design for the Yangtze River Delta Region
Logistics Systems Design for the Yangtze River Delta Region
 
Summarizing Siegel's Predictive Analytics
Summarizing Siegel's Predictive Analytics Summarizing Siegel's Predictive Analytics
Summarizing Siegel's Predictive Analytics
 
On Big Data
On Big DataOn Big Data
On Big Data
 
Linux for Education
Linux for EducationLinux for Education
Linux for Education
 
R and Rcmdr Statistical Software
R and Rcmdr Statistical SoftwareR and Rcmdr Statistical Software
R and Rcmdr Statistical Software
 

Recently uploaded

Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...limedy534
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样vhwb25kk
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...soniya singh
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfgstagge
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDRafezzaman
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFAAndrei Kaleshka
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...Suhani Kapoor
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Sapana Sha
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...Florian Roscheck
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一fhwihughh
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPramod Kumar Srivastava
 
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Bookvip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Bookmanojkuma9823
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptSonatrach
 

Recently uploaded (20)

Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
E-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptxE-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptx
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
 
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdf
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFA
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
 
Call Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort ServiceCall Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort Service
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
 
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Bookvip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
 

Introduction to Excel VBA/Macros

  • 1. Introduction to Excel VBA/Macros: Some Examples on Logistics and Supply Chain Management Dr. Kang Mun Arturo Tan Assistant Professor Logistics and Supply Chain Management Data Analytics Yanbu University College
  • 2. General Outline A_Why does Excel VBA matter? B_ What is VBA? C_ How do we start with VBA? D_ Recording some macros. E_ Running the macros. F_ Functions and Sub_Routines. G_ The User Form. slideNo3 Thanks COVER
  • 3. A_ Why does Excel VBA Matter
  • 4. A_ Why does VBA Excel Matter Excel is widely used across the world.
  • 5. A_ Why does VBA Excel Matter Excel is widely used across the world. Many corporate data, both structured and unstructured are in Excel.
  • 6. A_ Why does VBA Excel Matter Excel is widely used across the world. Many corporate data, both structured and unstructured are in Excel. Processing of data residing in Excel has become a routine work for many professionals.
  • 7. A_ Why does VBA Excel Matter Excel is widely used across the world. Many corporate data, both structured and unstructured are in Excel. Processing of data residing in Excel has become a routine work for many professionals. Automating this work could be an added advantage for the students who are entering the workforce. BackToTOC
  • 8. B_ What is VBA VBA stands for Visual Basic for Application. It is very similar to Visual Basic in form and structure. It works with Excel, Word, Access, Powerpoint and Outlook.
  • 9. Theory: For Excel, it deals with Excel Object Model. Object, intuitively, is like an XLNoid – a robot. Method is a call to action. Property is a data stored in that data basket, with the XLNoid constantly checking, and deciding if an action is needed.
  • 10. Theory: Overall Structure Application Project Worksheets Modules User_Form Macro Window Buttons Call Form Read/Write Data
  • 11. For Excel, it deals with Excel Object Model. Application Workbook Worksheets Range Cell BackToTOC BackTo_B
  • 12. C_ How do we start with Excel VBA Check for Activation Demo for Start Up Tan_C_Slide
  • 13. C_ How do we start with Excel VBA
  • 14. C_ How do we start with Excel VBA
  • 15. C_ How do we start with Excel VBA
  • 16. C_ How do we start with Excel VBA
  • 17. C_ How do we start with Excel VBA BackToTOC BackToC
  • 18. D_ Recording some VBA Macros Show Recording Process Tan_D_Slide
  • 19. D_ Recording some VBA Macros
  • 20. D_ Recording some VBA Macros
  • 21. D_ Recording some VBA Macros
  • 22. D_ Recording some VBA Macros
  • 23. D_ Recording some VBA Macros
  • 24. D_ Recording some VBA Macros Overall code
  • 25. D_ Recording some VBA Macros R[ Up/Down CellDistance] C[Left/Right CellDistance] Focusing on the formula: “R[-4] C + R[-3] C - R[-2] C “
  • 26. D_ Recording some VBA Macros ActiveCell.Offset( Up/Down CellStep, Left/Right CellStep) Relative Recording
  • 27. D_ Recording some VBA Macros Calling both MyMacro01 and MyMacro02
  • 28. D_ Recording some VBA Macros
  • 29. D_ Recording some VBA Macros
  • 30. D_ Recording some VBA Macros Clearing the area BackToTOC BackToD
  • 31. E_ Running the macros Alt+F8 Analyzing the recorded macros Tan_E_Slide
  • 32. E_ Running the macros
  • 33. E_ Running the macros
  • 34. E_ Running the macros BackToTOC BackToE
  • 35. F_ Functions and Sub Routines Cell To Fill Up a Cell with a Value To Fill Up a Cell with a Formula To Read a Cell’s Value
  • 36. F_ Functions and Sub Routines BegInvy + Receipts – Issuances = EndInvy As a function: As a subprocedure: Demo for Coding of Sub proc and Functions Tan_FA_Slide
  • 37. F_ Functions and Sub Routines EoQ = Sqrt (2 DS / H ) D = Demand for a Year S = Cost for each Ordering H = Holding Cost per Item per Year Demo for Preparing A report BackToTOC BackToF Tan_FA_Slide
  • 38. Fc1_ General Example Option Explicit Sub MyMacroGetMax() Dim q As Variant Dim x(100) As Integer Dim i As Integer, nPtr As Integer Dim Start As Integer, Last As Integer, Num As Integer Dim AssumedHeaviest, Heaviest As Integer ' Defining the array q = Array(7, 2, 3, 20, 15, 6, 35, 12, 9, 5, 18, 23, _ 9, 16, 22, 10) Demo for Straight Coding Tan_FC_Slide
  • 39. Fc2_ General Example Start = LBound(q) MsgBox "StartBoxNo is " & Start Last = UBound(q) MsgBox "LastBoxNo is " & Last Num = Last - Start + 1 MsgBox "BoxCount is " & Num ' = = == = = = = = = ' transferring the content of container q to container x. ‘ container x is a temporary place for comparison. ' ========= = = = = = For i = Start To Last x(i) = q(i) Next i ' = = = = = = = = = = =
  • 40. Fc3_ General Example ' = = ' assume the first box to be the heaviest. ' = = = AssumedHeaviest = x(Start) ‘// Start means the first box ' = = = = For nPtr = Start + 1 To Last ‘// Start+1 means the second box If x(nPtr) > AssumedHeaviest Then AssumedHeaviest = x(nPtr) End If Next nPtr Heaviest = AssumedHeaviest MsgBox "Heaviest is " & Heaviest End Sub BackToTOC BackToFc
  • 41. G_ UserForm Example Call Demo G Tan_G_Slide
  • 48. H_ Overall Structure Application Project Worksheets Modules User_Form Macro Window Buttons Call Form Read/Write Data BackToTOC