Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject...
Transcript of Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject...
![Page 1: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/1.jpg)
![Page 2: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/2.jpg)
![Page 3: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/3.jpg)
![Page 4: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/4.jpg)
![Page 5: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/5.jpg)
![Page 6: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/6.jpg)
![Page 7: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/7.jpg)
→
![Page 8: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/8.jpg)
![Page 9: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/9.jpg)
![Page 10: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/10.jpg)
Option Explicit
![Page 11: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/11.jpg)
Sub Myroutine()
End Sub
Myroutine()
![Page 12: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/12.jpg)
![Page 13: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/13.jpg)
![Page 14: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/14.jpg)
Dim
Dim mystring As String
Dim dbl As Double
Dim num As Integer
Dim rng As Range
=
mystring = “string”
num = 5
Set rng = Range(“A1:B3”)
![Page 15: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/15.jpg)
![Page 16: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/16.jpg)
MsgBox(“Prompt”)
![Page 17: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/17.jpg)
?Worksheets.Count
?Range(“B2”).Value
Debug.Print
![Page 18: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/18.jpg)
If
If condition Then
[statements]
[ElseIf elseifcondition Then
elseifstatements]
[Else
elsestatements]
End If
condition statements elseifconditionelseifstatements elsestatements
ElseIf
![Page 19: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/19.jpg)
While
While condition
statements
Wend
statements condition FALSE
condition TRUE
![Page 20: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/20.jpg)
For
For counter = start To end [Step increment]
statements
Next [counter]
counter
For i = 0 to 3 i = 0, 1, 2, 3
For i = 2 to 7 Step 2 i = 2, 4, 6
For i = 5 to 0 Step -3 i = 5, 2
![Page 21: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/21.jpg)
For Each
For Each cell In range
statements
Next
cell range
range cell
![Page 22: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/22.jpg)
Dim array(5) as Integer
ReDim array(10)
ReDim Preserve array(15)
array(0) = 5
![Page 23: Excel Workshop III Introduction to VBA in Excelactuary/meetingsAndWorkshops/... · VBAProject (FUNCRES.XLAM) Microsoft Excel Objects È]" Modules RibbonX Code BRUIN ACTUARIAL SOCIETY](https://reader035.fdocuments.in/reader035/viewer/2022071211/60230e6cbdbaf14baa5c82cb/html5/thumbnails/23.jpg)
Function MyFunction(param1 As dtype, param2 As dtype, …) As dtype
statements
MyFunction = value
End Function