SlideShare uma empresa Scribd logo
1 de 19
VBA Programming for Excel 
 Review Excel Objects 
 Excel Methods 
 Identifying Specific Cells 
 Review Functions for Excel 
 Custom Menus
Range Objects 
 Range(Name) 
 Name: text string 
 “B3”,”Input” 
 Offset 
 Range(“B3”).Offset(2,1) = Range(“C5”) 
 Offset numbers can be called 
MyNumber = 3 
Range(“D4”).Offset(myNumber, -1).Select 
<Results: Cursor ends up in cell C7>
Default Objects 
 ActiveCell 
 ActiveCell.Offset(0,1).Select 
 RowNum = ActiveCell.Row 
 ActiveSheet 
 ActiveSheet.Name = “Data” 
 ActiveSheet.Visible = VeryHidden 
 Selection 
 Selection.Clear
What does this code do? 
ActiveCell.Offset(Range(“B2”),-2) = [b4]/4 
4
Controlling Objects 
 Use assignment statements to change 
objects or properties 
 Different effects, similar results 
 Range(“F3”).Value = Range(“D3”).Value*15 
 Range (“F3”).Formula = “=D3*15” 
 First form enter a number – no updates! 
 Second form enters a formula
Collections 
 Worksheets 
 Worksheets(1) 
 Worksheets(“Sheet2”) 
 Columns 
Columns(“C:D”).HorizontalAlignment = xlCenter 
 Rows 
Rows(5).RowHeight = 19.5 
 Note difference between Row and 
Rows
Excel Methods 
 Record macros to define 
 Copy, Paste 
Range(“B3:D6”).Select 
Selection.Copy 
 Sort
Find a Given Cell 
 GoTo 
 Edit, Goto, Special 
 Last Cell 
 Current Region 
 {End}{Down} 
 Find first column in the last row
Look-ups 
 VLookUp(value, table, col_num, close) 
 Value: item to find 
 Table: range of data to search 
 Must be sorted by 1st column 
 Col_num: which column has data? 
 Close: true or false 
 True: select nearest match – always finds 
 False: find exact, or return #N/A
VLookUp 
Value to LookUp 
Search range 
Return column 
True: find 
closest match
Spreadsheet Functions in VBA 
 Application.WorkSheetFunction.Name(Arguments) 
Application.WorksheetFunction.Today() 
 Cell addresses must appear as ranges 
Application.WorkSheetFunction.IsNumber(Range(“B3”)) 
 Most worksheet functions have a VBA equivalent 
 Functions must be used in assignment statements 
vAns = Application.WorkSheetFunction. _ 
vLookup(Range(“A10”), Range(“A2:C8”), 3, True) 
vOut = Range(“A10”).formula & “ lives in “ vAns 
MsgBox vOut
Find() 
 VBA Function – not available on sheet 
 Expression.Find(What) 
 Expression must define a range on the 
spreadsheet 
 Returns Range location of first match 
 Expression range need not be sorted 
 If no match is found, it returns Nothing
Find( ) Function 
Range(“C10”).Value = _ 
Range(“A2:A8”).Find(“Gene”).Offset(0,2).Value 
Looks in cells A2:A8 for 
“Gene”, 
returns [A5] 
Offsets 2 cells right from [A5] 
returns [C5] 
Finds the value in [C5] = 58 
Puts the value 58 in [C10]
User Defined Functions 
 You can write your own custom functions 
 Decide what information will be passed in 
(Arguments) 
 Decide what value will be returned 
 Decide how VBA will use the arguments to 
calculate the returned value 
 Example: Determine employee bunuses 
 Argument: Amount of sales 
 Return value: Bonus amount 
 Bonus = 2% if Sales > $50,000
User-defined Functions 
 Form: Function Name(Arguments) 
 Unlike Sub – the name of the function 
must be repeated in the code 
Function Bonus(Sales) 
If Sales > 50000 Then 
Bonus = Sales * 0.02 
Else 
Bonus = 0 
End If 
End Function
Using Custom Functions 
 Functions can be called from another sub 
vSales = Range(“B3”).Value 
vBonus = Bonus(vSales) 
Range(“C3”).Value = vBonus 
 Functions can be used in the spreadsheet 
 Use Function Generator [fx] 
 Look under “User-defined” 
 Place cursor in [C3], write: 
=Bonus(B3) 
 Note how the results differ! 
 See VBAFunctions.xls in the handouts
Custom Menus 
 Define Variables 
 Use Set to define contents 
Dim myButton As CommandBarButton 
Set myButton = CommandBars("Worksheet Menu Bar")_ 
.Controls("Tools").Controls.Add 
With myButton 
.Caption = "Say Hi" 
.MoveBefore:=4 
.OnAction = "SayHi" 
.FaceId = 2174 
End With 
Caption: Words in menu list 
MoveBefore: Position in list 
OnAction: Macro to call 
FaceID: Icon to display
Removing Menu Items 
 Search the existing buttons 
 Remove identified items 
For Each Item In CommandBars("Worksheet Menu Bar")_ 
.Controls("Tools").Controls 
If Item.Caption = "Say Hi" Then 
Item.Delete 
Exit For 
End If 
Next Item
Activating Custom Menus 
 Menu code goes in a macro 
 Macro must be run to make menu 
appear or disappear 
 Use WorkBook_Open to add menues 
 Use WorkBook_BeforeClose to remove 
 See SayHi.xls in the handouts

Mais conteúdo relacionado

Mais procurados

Functions oracle (pl/sql)
Functions oracle (pl/sql)Functions oracle (pl/sql)
Functions oracle (pl/sql)harman kaur
 
Implementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord modelsImplementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord modelsKostyantyn Stepanyuk
 
Writing Group Functions - DBMS
Writing Group Functions - DBMSWriting Group Functions - DBMS
Writing Group Functions - DBMSSolaiman Hridoy
 
EAV Sytem- Magento EAV Model
EAV Sytem- Magento EAV ModelEAV Sytem- Magento EAV Model
EAV Sytem- Magento EAV ModelKhoa Truong Dinh
 
Introduction To Oracle Sql
Introduction To Oracle SqlIntroduction To Oracle Sql
Introduction To Oracle SqlAhmed Yaseen
 
Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2Marlon Luz
 
Using single row functions to customize output
Using single row functions to customize outputUsing single row functions to customize output
Using single row functions to customize outputSyed Zaid Irshad
 
MSc COMPUTER APPLICATION
MSc COMPUTER APPLICATIONMSc COMPUTER APPLICATION
MSc COMPUTER APPLICATIONMugdhaSharma11
 
Excel formulas-manual
Excel formulas-manualExcel formulas-manual
Excel formulas-manualsrv1972
 
Entity Attribute Value (Eav)
Entity   Attribute   Value (Eav)Entity   Attribute   Value (Eav)
Entity Attribute Value (Eav)Tâm
 
Geometria analitica con geogebra secme 22589
Geometria analitica con geogebra secme 22589Geometria analitica con geogebra secme 22589
Geometria analitica con geogebra secme 22589EmilioEscalanteHerna
 
Les02 (restricting and sorting data)
Les02 (restricting and sorting data)Les02 (restricting and sorting data)
Les02 (restricting and sorting data)Achmad Solichin
 

Mais procurados (20)

Functions oracle (pl/sql)
Functions oracle (pl/sql)Functions oracle (pl/sql)
Functions oracle (pl/sql)
 
Oracle: Basic SQL
Oracle: Basic SQLOracle: Basic SQL
Oracle: Basic SQL
 
Implementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord modelsImplementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord models
 
Writing Group Functions - DBMS
Writing Group Functions - DBMSWriting Group Functions - DBMS
Writing Group Functions - DBMS
 
EAV Sytem- Magento EAV Model
EAV Sytem- Magento EAV ModelEAV Sytem- Magento EAV Model
EAV Sytem- Magento EAV Model
 
Les06
Les06Les06
Les06
 
Introduction To Oracle Sql
Introduction To Oracle SqlIntroduction To Oracle Sql
Introduction To Oracle Sql
 
Python Programming
Python Programming Python Programming
Python Programming
 
Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2
 
Using single row functions to customize output
Using single row functions to customize outputUsing single row functions to customize output
Using single row functions to customize output
 
Get more from excel
Get more from excelGet more from excel
Get more from excel
 
MSc COMPUTER APPLICATION
MSc COMPUTER APPLICATIONMSc COMPUTER APPLICATION
MSc COMPUTER APPLICATION
 
Sql functions
Sql functionsSql functions
Sql functions
 
Excel formulas-manual
Excel formulas-manualExcel formulas-manual
Excel formulas-manual
 
Les07
Les07Les07
Les07
 
Entity Attribute Value (Eav)
Entity   Attribute   Value (Eav)Entity   Attribute   Value (Eav)
Entity Attribute Value (Eav)
 
Geometria analitica con geogebra secme 22589
Geometria analitica con geogebra secme 22589Geometria analitica con geogebra secme 22589
Geometria analitica con geogebra secme 22589
 
Practica dos
Practica dosPractica dos
Practica dos
 
Dbms lab questions
Dbms lab questionsDbms lab questions
Dbms lab questions
 
Les02 (restricting and sorting data)
Les02 (restricting and sorting data)Les02 (restricting and sorting data)
Les02 (restricting and sorting data)
 

Destaque

Materi Pemfaktoran Persamaan Kuadrat
Materi Pemfaktoran Persamaan KuadratMateri Pemfaktoran Persamaan Kuadrat
Materi Pemfaktoran Persamaan KuadratIndah Lestari
 
Matematik Tambahan: Persamaan kuadratik
Matematik Tambahan: Persamaan kuadratikMatematik Tambahan: Persamaan kuadratik
Matematik Tambahan: Persamaan kuadratikCikgu Marzuqi
 
PPT Puzzle Milus 1
PPT Puzzle Milus 1PPT Puzzle Milus 1
PPT Puzzle Milus 1Indah Sari
 
Ppt kpk dan fpb.pptx vvvv
Ppt kpk dan fpb.pptx vvvvPpt kpk dan fpb.pptx vvvv
Ppt kpk dan fpb.pptx vvvvRela Tusriyanto
 
Dokumen.tips kelas 7-matematika-bab-1-bilangan-bulat (2)
Dokumen.tips kelas 7-matematika-bab-1-bilangan-bulat (2)Dokumen.tips kelas 7-matematika-bab-1-bilangan-bulat (2)
Dokumen.tips kelas 7-matematika-bab-1-bilangan-bulat (2)Antoni Antoni
 
Bahan Ajar Bilangan Bulat
Bahan Ajar Bilangan BulatBahan Ajar Bilangan Bulat
Bahan Ajar Bilangan BulatDara-71
 
Soal UTS TIK kelas 7 semester 2 hardware
Soal UTS TIK kelas 7 semester 2 hardwareSoal UTS TIK kelas 7 semester 2 hardware
Soal UTS TIK kelas 7 semester 2 hardwareCitra Aero
 
SOAL UAS GANJIL MATEMATIKA SMP KELAS VII 2015/2016
SOAL UAS GANJIL MATEMATIKA SMP KELAS VII 2015/2016SOAL UAS GANJIL MATEMATIKA SMP KELAS VII 2015/2016
SOAL UAS GANJIL MATEMATIKA SMP KELAS VII 2015/2016Budi Haryono
 
Soal unas &amp; pembahasan
Soal unas  &amp; pembahasanSoal unas  &amp; pembahasan
Soal unas &amp; pembahasanAnnisa Rahmaw
 

Destaque (14)

Materi Pemfaktoran Persamaan Kuadrat
Materi Pemfaktoran Persamaan KuadratMateri Pemfaktoran Persamaan Kuadrat
Materi Pemfaktoran Persamaan Kuadrat
 
SOAL BILANGAN BULAT
SOAL BILANGAN BULATSOAL BILANGAN BULAT
SOAL BILANGAN BULAT
 
1. bab bilangan bulat
1. bab bilangan bulat1. bab bilangan bulat
1. bab bilangan bulat
 
Matematik Tambahan: Persamaan kuadratik
Matematik Tambahan: Persamaan kuadratikMatematik Tambahan: Persamaan kuadratik
Matematik Tambahan: Persamaan kuadratik
 
BAB I : Operasi Hitung Bilangan
BAB I : Operasi Hitung BilanganBAB I : Operasi Hitung Bilangan
BAB I : Operasi Hitung Bilangan
 
PPT Puzzle Milus 1
PPT Puzzle Milus 1PPT Puzzle Milus 1
PPT Puzzle Milus 1
 
Ppt kpk dan fpb.pptx vvvv
Ppt kpk dan fpb.pptx vvvvPpt kpk dan fpb.pptx vvvv
Ppt kpk dan fpb.pptx vvvv
 
Dokumen.tips kelas 7-matematika-bab-1-bilangan-bulat (2)
Dokumen.tips kelas 7-matematika-bab-1-bilangan-bulat (2)Dokumen.tips kelas 7-matematika-bab-1-bilangan-bulat (2)
Dokumen.tips kelas 7-matematika-bab-1-bilangan-bulat (2)
 
Bahan Ajar Bilangan Bulat
Bahan Ajar Bilangan BulatBahan Ajar Bilangan Bulat
Bahan Ajar Bilangan Bulat
 
Operasi hitung bilangan bulat
Operasi hitung bilangan bulatOperasi hitung bilangan bulat
Operasi hitung bilangan bulat
 
Soal mtk
Soal mtkSoal mtk
Soal mtk
 
Soal UTS TIK kelas 7 semester 2 hardware
Soal UTS TIK kelas 7 semester 2 hardwareSoal UTS TIK kelas 7 semester 2 hardware
Soal UTS TIK kelas 7 semester 2 hardware
 
SOAL UAS GANJIL MATEMATIKA SMP KELAS VII 2015/2016
SOAL UAS GANJIL MATEMATIKA SMP KELAS VII 2015/2016SOAL UAS GANJIL MATEMATIKA SMP KELAS VII 2015/2016
SOAL UAS GANJIL MATEMATIKA SMP KELAS VII 2015/2016
 
Soal unas &amp; pembahasan
Soal unas  &amp; pembahasanSoal unas  &amp; pembahasan
Soal unas &amp; pembahasan
 

Semelhante a Excell vba

Semelhante a Excell vba (20)

belajar VBA
belajar VBAbelajar VBA
belajar VBA
 
Working with shapes
Working with shapesWorking with shapes
Working with shapes
 
Introduction to DAX Language
Introduction to DAX LanguageIntroduction to DAX Language
Introduction to DAX Language
 
MA3696 Lecture 9
MA3696 Lecture 9MA3696 Lecture 9
MA3696 Lecture 9
 
Excel 2007 Unit H
Excel 2007 Unit HExcel 2007 Unit H
Excel 2007 Unit H
 
OBIEE 12c Advanced Analytic Functions
OBIEE 12c Advanced Analytic FunctionsOBIEE 12c Advanced Analytic Functions
OBIEE 12c Advanced Analytic Functions
 
Ms excel
Ms excelMs excel
Ms excel
 
1.2 Zep Excel.pptx
1.2 Zep Excel.pptx1.2 Zep Excel.pptx
1.2 Zep Excel.pptx
 
Excel.useful fns
Excel.useful fnsExcel.useful fns
Excel.useful fns
 
Excel Macros and VBA Demo.docx
Excel Macros and VBA Demo.docxExcel Macros and VBA Demo.docx
Excel Macros and VBA Demo.docx
 
Excel Macros and VBA Demo.docx
Excel Macros and VBA Demo.docxExcel Macros and VBA Demo.docx
Excel Macros and VBA Demo.docx
 
Python Lecture 4
Python Lecture 4Python Lecture 4
Python Lecture 4
 
Tutorials on Macro
Tutorials on MacroTutorials on Macro
Tutorials on Macro
 
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
 
Mdx Basics
Mdx BasicsMdx Basics
Mdx Basics
 
What are Tableau Functions? Edureka
What are Tableau Functions? EdurekaWhat are Tableau Functions? Edureka
What are Tableau Functions? Edureka
 
6 Function Built In (Excel 2019 dn 365).pptx
6 Function Built In (Excel 2019 dn 365).pptx6 Function Built In (Excel 2019 dn 365).pptx
6 Function Built In (Excel 2019 dn 365).pptx
 
Excel functions, formulas, Prepared by singh institute RK Puram
Excel functions, formulas, Prepared by singh institute RK PuramExcel functions, formulas, Prepared by singh institute RK Puram
Excel functions, formulas, Prepared by singh institute RK Puram
 
C# excel bar chart
C# excel bar chartC# excel bar chart
C# excel bar chart
 
Project advance itt
Project advance ittProject advance itt
Project advance itt
 

Último

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
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
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
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
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
 
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
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
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
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
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
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
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
 
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
 

Último (20)

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
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.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)
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
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
 
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
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
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
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
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Ă...
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
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
 
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
 

Excell vba

  • 1. VBA Programming for Excel  Review Excel Objects  Excel Methods  Identifying Specific Cells  Review Functions for Excel  Custom Menus
  • 2. Range Objects  Range(Name)  Name: text string  “B3”,”Input”  Offset  Range(“B3”).Offset(2,1) = Range(“C5”)  Offset numbers can be called MyNumber = 3 Range(“D4”).Offset(myNumber, -1).Select <Results: Cursor ends up in cell C7>
  • 3. Default Objects  ActiveCell  ActiveCell.Offset(0,1).Select  RowNum = ActiveCell.Row  ActiveSheet  ActiveSheet.Name = “Data”  ActiveSheet.Visible = VeryHidden  Selection  Selection.Clear
  • 4. What does this code do? ActiveCell.Offset(Range(“B2”),-2) = [b4]/4 4
  • 5. Controlling Objects  Use assignment statements to change objects or properties  Different effects, similar results  Range(“F3”).Value = Range(“D3”).Value*15  Range (“F3”).Formula = “=D3*15”  First form enter a number – no updates!  Second form enters a formula
  • 6. Collections  Worksheets  Worksheets(1)  Worksheets(“Sheet2”)  Columns Columns(“C:D”).HorizontalAlignment = xlCenter  Rows Rows(5).RowHeight = 19.5  Note difference between Row and Rows
  • 7. Excel Methods  Record macros to define  Copy, Paste Range(“B3:D6”).Select Selection.Copy  Sort
  • 8. Find a Given Cell  GoTo  Edit, Goto, Special  Last Cell  Current Region  {End}{Down}  Find first column in the last row
  • 9. Look-ups  VLookUp(value, table, col_num, close)  Value: item to find  Table: range of data to search  Must be sorted by 1st column  Col_num: which column has data?  Close: true or false  True: select nearest match – always finds  False: find exact, or return #N/A
  • 10. VLookUp Value to LookUp Search range Return column True: find closest match
  • 11. Spreadsheet Functions in VBA  Application.WorkSheetFunction.Name(Arguments) Application.WorksheetFunction.Today()  Cell addresses must appear as ranges Application.WorkSheetFunction.IsNumber(Range(“B3”))  Most worksheet functions have a VBA equivalent  Functions must be used in assignment statements vAns = Application.WorkSheetFunction. _ vLookup(Range(“A10”), Range(“A2:C8”), 3, True) vOut = Range(“A10”).formula & “ lives in “ vAns MsgBox vOut
  • 12. Find()  VBA Function – not available on sheet  Expression.Find(What)  Expression must define a range on the spreadsheet  Returns Range location of first match  Expression range need not be sorted  If no match is found, it returns Nothing
  • 13. Find( ) Function Range(“C10”).Value = _ Range(“A2:A8”).Find(“Gene”).Offset(0,2).Value Looks in cells A2:A8 for “Gene”, returns [A5] Offsets 2 cells right from [A5] returns [C5] Finds the value in [C5] = 58 Puts the value 58 in [C10]
  • 14. User Defined Functions  You can write your own custom functions  Decide what information will be passed in (Arguments)  Decide what value will be returned  Decide how VBA will use the arguments to calculate the returned value  Example: Determine employee bunuses  Argument: Amount of sales  Return value: Bonus amount  Bonus = 2% if Sales > $50,000
  • 15. User-defined Functions  Form: Function Name(Arguments)  Unlike Sub – the name of the function must be repeated in the code Function Bonus(Sales) If Sales > 50000 Then Bonus = Sales * 0.02 Else Bonus = 0 End If End Function
  • 16. Using Custom Functions  Functions can be called from another sub vSales = Range(“B3”).Value vBonus = Bonus(vSales) Range(“C3”).Value = vBonus  Functions can be used in the spreadsheet  Use Function Generator [fx]  Look under “User-defined”  Place cursor in [C3], write: =Bonus(B3)  Note how the results differ!  See VBAFunctions.xls in the handouts
  • 17. Custom Menus  Define Variables  Use Set to define contents Dim myButton As CommandBarButton Set myButton = CommandBars("Worksheet Menu Bar")_ .Controls("Tools").Controls.Add With myButton .Caption = "Say Hi" .MoveBefore:=4 .OnAction = "SayHi" .FaceId = 2174 End With Caption: Words in menu list MoveBefore: Position in list OnAction: Macro to call FaceID: Icon to display
  • 18. Removing Menu Items  Search the existing buttons  Remove identified items For Each Item In CommandBars("Worksheet Menu Bar")_ .Controls("Tools").Controls If Item.Caption = "Say Hi" Then Item.Delete Exit For End If Next Item
  • 19. Activating Custom Menus  Menu code goes in a macro  Macro must be run to make menu appear or disappear  Use WorkBook_Open to add menues  Use WorkBook_BeforeClose to remove  See SayHi.xls in the handouts