update,
2
wenarama/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
**/draft*
|
||||||
|
**/*.7z
|
BIN
wenarama/_original/Source_File_PRC_Data_Aug_v1.xlsb
Normal file
BIN
wenarama/_original/Workfile_GC_PRC_Aug_2023.xlsb
Normal file
2
wenarama/clean.bat
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
rmdir *.bas
|
||||||
|
rmdir *.cls
|
BIN
wenarama/column_name/04D83F23-A980-47AD-A4B3-EFB3739BB9E8.jpeg
Normal file
After Width: | Height: | Size: 6.7 MiB |
BIN
wenarama/column_name/40404C2A-BAC7-47EA-96C6-D311DF0B171E.jpeg
Normal file
After Width: | Height: | Size: 5.2 MiB |
BIN
wenarama/column_name/4436361E-73C1-46C3-8C51-D67CD6DD4387.jpeg
Normal file
After Width: | Height: | Size: 5.7 MiB |
BIN
wenarama/column_name/452A5A67-C0B3-47A8-9420-5CF8E7F24314.jpeg
Normal file
After Width: | Height: | Size: 5.2 MiB |
BIN
wenarama/column_name/5B49EC85-8E69-4889-8B06-B7595320AE59.jpeg
Normal file
After Width: | Height: | Size: 5.0 MiB |
BIN
wenarama/column_name/6280E5B6-632B-44C9-8B36-BCD9E2C17763.jpeg
Normal file
After Width: | Height: | Size: 5.6 MiB |
BIN
wenarama/column_name/6A7F1BC6-F7E7-46EA-BAF1-1F8A60E1C982.jpeg
Normal file
After Width: | Height: | Size: 4.4 MiB |
BIN
wenarama/column_name/710F9A56-E9A6-42D6-BA2C-DF7F3AE3725C.jpeg
Normal file
After Width: | Height: | Size: 4.4 MiB |
BIN
wenarama/column_name/713DEF12-4034-4794-9095-E6B95E48BC97.jpeg
Normal file
After Width: | Height: | Size: 4.3 MiB |
BIN
wenarama/column_name/8F659A34-2520-4A1B-A4DF-C6397B87298D.jpeg
Normal file
After Width: | Height: | Size: 4.4 MiB |
7
wenarama/gitUpdate.bat
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
git status .
|
||||||
|
|
||||||
|
@pause
|
||||||
|
|
||||||
|
git add .
|
||||||
|
git commit -m"update wenarama,"
|
||||||
|
start git push
|
44
wenarama/meta.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
tags: [vba, excel, accounting, banking]
|
||||||
|
---
|
||||||
|
|
||||||
|
# wenarama
|
||||||
|
|
||||||
|
## balance history
|
||||||
|
|
||||||
|
Q:
|
||||||
|
Hi, 你呢兩日有時間講個電話,傾吓用咩模式比較好?
|
||||||
|
|
||||||
|
A:
|
||||||
|
ok ar, 可以安排,通電話方面夜晚 8 ~ 11 方便嘛?
|
||||||
|
|
||||||
|
Q:
|
||||||
|
我諗法係,每次上堂之前我會 send excel files 俾你,大概話俾你知我想做乜嘢。跟住上堂可以教我。
|
||||||
|
不過可能頭幾次要講解下 IDE, vba syntax etc
|
||||||
|
|
||||||
|
A:
|
||||||
|
ok ar, 可以的話請預早一兩日 send 過黎 : )
|
||||||
|
|
||||||
|
### notes
|
||||||
|
|
||||||
|
Q: 不過可能頭幾次要講解下 IDE, vba syntax etc
|
||||||
|
|
||||||
|
我會比較傾向我做完,再同你講下點解我要咁做
|
||||||
|
如果你係連 syntax 都未清楚的話,咁可以順手睇埋/問埋
|
||||||
|
|
||||||
|
因為我覺得單獨 背/記 syntax 係垃圾行為,
|
||||||
|
其實 點樣用/幾時用 先係要學嘅事
|
||||||
|
|
||||||
|
syntax 你 上網/自己寫寫下果個 code base 都有得抄,
|
||||||
|
唔需要刻意去 學/背/記
|
||||||
|
|
||||||
|
當然我都可以比個 kick off 你,
|
||||||
|
用人話講即係好似燒味拼盤咁樣樣有 D 輕輕介紹一下
|
||||||
|
|
||||||
|
但係 in-deep 到你用到果陣時就自然會知 / google
|
||||||
|
|
||||||
|
[[slides/slide-deck]]
|
||||||
|
|
||||||
|
[//begin]: # "Autogenerated link references for markdown compatibility"
|
||||||
|
[slides/slide-deck]: slides/slide-deck.md "Excel VBA"
|
||||||
|
[//end]: # "Autogenerated link references"
|
BIN
wenarama/slides/excel-vba.pdf
Normal file
BIN
wenarama/slides/images/backdrop.jpg
(Stored with Git LFS)
Normal file
BIN
wenarama/slides/images/excel.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides/images/thank_you.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides/images/vba-button.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides/images/vba-debug-menu.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides/images/vba-developer-tab.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides/images/vba-enable-developer-menu-1.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides/images/vba-enable-developer-menu-2.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides/images/vba-enable-macro.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides/images/vba-file-menu.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides/images/vba-helloworld-run.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides/images/vba-ide.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides/images/vba-module-menu.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides/images/vba-module.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides/images/vba-run-menu.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides/images/vba-save-as-xlsm.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides/images/vba-save-with-macro.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides/images/vba-start.png
(Stored with Git LFS)
Normal file
344
wenarama/slides/index.html
Normal file
3715
wenarama/slides/package-lock.json
generated
Normal file
18
wenarama/slides/package.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"name": "slides",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"ren_html": "marp slide-deck.md -o index.html",
|
||||||
|
"ren_pdf": "marp --allow-local-files --pdf-notes slide-deck.md -o index.pdf"
|
||||||
|
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"@marp-team/marp-cli": "^3.3.1"
|
||||||
|
}
|
||||||
|
}
|
396
wenarama/slides/slide-deck.md
Normal file
@@ -0,0 +1,396 @@
|
|||||||
|
---
|
||||||
|
theme: gaia
|
||||||
|
_class: lead
|
||||||
|
paginate: true
|
||||||
|
backgroundColor: #fff
|
||||||
|
backgroundImage: url('./images/backdrop.jpg')
|
||||||
|
---
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
# **Excel VBA**
|
||||||
|
|
||||||
|
Excel VBA introduction
|
||||||
|
|
||||||
|
https://louiscklaw.github.io/
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA IDE
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Enable VBA IDE 1/2
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
### VBA Start IDE
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Save with macro enabled workbook 1/2
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Save with macro enabled workbook 2/2
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - File menu
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
<!-- "run", "interrupt", "break point" -->
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Run menu
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
<!-- "run", "interrupt", "break point" -->
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Debug menu
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
<!-- "step into", "step over" -->
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Module
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA looping - For loop 1/2
|
||||||
|
|
||||||
|
```VB
|
||||||
|
For counter = start To end [Step stepcount]
|
||||||
|
[statement 1]
|
||||||
|
....
|
||||||
|
[statement n]
|
||||||
|
[Exit For]
|
||||||
|
[statement 11]
|
||||||
|
....
|
||||||
|
[statement n]
|
||||||
|
Next
|
||||||
|
```
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- please draft me a sample of VBA for loop -->
|
||||||
|
### VBA looping - For loop 2/2
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Sub ForLoopExample()
|
||||||
|
Dim i As Integer
|
||||||
|
|
||||||
|
' Loop from 1 to 5
|
||||||
|
For i = 1 To 5
|
||||||
|
' Print the value of i
|
||||||
|
Debug.Print i
|
||||||
|
Next i
|
||||||
|
|
||||||
|
' Loop from 10 to 1 with a step of -1
|
||||||
|
For i = 10 To 1 Step -1
|
||||||
|
' Print the value of i
|
||||||
|
Debug.Print i
|
||||||
|
Next i
|
||||||
|
End Sub
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA looping - While loop 1/2
|
||||||
|
|
||||||
|
```
|
||||||
|
While condition(s)
|
||||||
|
[statements 1]
|
||||||
|
[statements 2]
|
||||||
|
...
|
||||||
|
[statements n]
|
||||||
|
Wend
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- please draft me a sample of VBA while loop -->
|
||||||
|
### VBA looping - While loop 2/2
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Sub WhileLoopExample()
|
||||||
|
Dim i As Integer
|
||||||
|
|
||||||
|
' Loop while i is less than or equal to 5
|
||||||
|
i = 1
|
||||||
|
While i <= 5
|
||||||
|
' Print the value of i
|
||||||
|
Debug.Print i
|
||||||
|
|
||||||
|
' Increment i by 1
|
||||||
|
i = i + 1
|
||||||
|
Wend
|
||||||
|
|
||||||
|
' Loop while i is greater than 0
|
||||||
|
i = 10
|
||||||
|
Do While i > 0
|
||||||
|
' Print the value of i
|
||||||
|
Debug.Print i
|
||||||
|
|
||||||
|
' Decrement i by 1
|
||||||
|
i = i - 1
|
||||||
|
Loop
|
||||||
|
End Sub
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Functions 1/2
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Function Functionname(parameter-list)
|
||||||
|
statement 1
|
||||||
|
.......
|
||||||
|
statement n
|
||||||
|
End Function
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- please draft me a sample of VBA function -->
|
||||||
|
### VBA - Functions 2/2
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Function AddNumbers(num1 As Double, num2 As Double) As Double
|
||||||
|
' Add two numbers and return the result
|
||||||
|
AddNumbers = num1 + num2
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Sub TestAddNumbers()
|
||||||
|
Dim result As Double
|
||||||
|
|
||||||
|
' Call the AddNumbers function and store the result in the 'result' variable
|
||||||
|
result = AddNumbers(5.5, 3.2)
|
||||||
|
|
||||||
|
' Display the result
|
||||||
|
MsgBox "The result is: " & result
|
||||||
|
End Sub
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
<!-- please draft me a sample of VBA Sub -->
|
||||||
|
### VBA - Subs 1/2
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Sub Area(x As Double, y As Double)
|
||||||
|
MsgBox x * y
|
||||||
|
End Sub
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
<!-- please draft me a sample of VBA Sub -->
|
||||||
|
### VBA - Subs 2/2
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Sub GreetUser(name As String)
|
||||||
|
' Display a greeting message with the provided name
|
||||||
|
MsgBox "Hello, " & name & "! Welcome to our program."
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub TestGreetUser()
|
||||||
|
' Call the GreetUser subroutine and pass a name
|
||||||
|
GreetUser "John"
|
||||||
|
End Sub
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Message Box
|
||||||
|
|
||||||
|
```VB
|
||||||
|
MsgBox(prompt[,buttons][,title][,helpfile,context])
|
||||||
|
```
|
||||||
|
|
||||||
|
TODO: screen capture of Msgbox
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Constants
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Const MyInteger As Integer = 42
|
||||||
|
Const myDate As Date = #2/2/2020#
|
||||||
|
Const myDay As String = "Sunday"
|
||||||
|
```
|
||||||
|
|
||||||
|
### VBA - Variables
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Dim MyInteger As Integer = 42
|
||||||
|
Dim myDate As Date = #2/2/2020#
|
||||||
|
Dim myDay As String = "Sunday"
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Arithmatic Operators
|
||||||
|
|
||||||
|
let A = 5, B = 10
|
||||||
|
|
||||||
|
sign | means/equals
|
||||||
|
-----|-----------------------
|
||||||
|
\+ | A + B will give 15
|
||||||
|
\- | A - B will give -5
|
||||||
|
\* | A * B will give 50
|
||||||
|
/ | B / A will give 2
|
||||||
|
% | B % A will give 0
|
||||||
|
^ | B ^ A will give 100000
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
### VBA - Comparison Operators
|
||||||
|
|
||||||
|
let A = 5, B = 10
|
||||||
|
|
||||||
|
sign | means/equals
|
||||||
|
-----|-------------------
|
||||||
|
= | (A = B) is False.
|
||||||
|
<> | (A <> B) is True.
|
||||||
|
\> | (A > B) is False.
|
||||||
|
< | (A < B) is True.
|
||||||
|
\>= | (A >= B) is False.
|
||||||
|
<= | (A <= B) is True.
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - If Statement 1/3
|
||||||
|
|
||||||
|
```VB
|
||||||
|
If(boolean_expression) Then
|
||||||
|
Statement 1
|
||||||
|
.....
|
||||||
|
.....
|
||||||
|
Statement n
|
||||||
|
End If
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - If Elseif - Else statement 2/3
|
||||||
|
|
||||||
|
```VB
|
||||||
|
If(boolean_expression) Then
|
||||||
|
Statement 1
|
||||||
|
.....
|
||||||
|
Statement n
|
||||||
|
ElseIf (boolean_expression) Then
|
||||||
|
Statement 1
|
||||||
|
.....
|
||||||
|
Statement n
|
||||||
|
ElseIf (boolean_expression) Then
|
||||||
|
Statement 1
|
||||||
|
.....
|
||||||
|
Statement n
|
||||||
|
Else
|
||||||
|
Statement 1
|
||||||
|
.....
|
||||||
|
Statement n
|
||||||
|
End If
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - If statement example 3/3
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Sub CheckNumber(number As Integer)
|
||||||
|
' Check if the number is greater than 10
|
||||||
|
If number > 10 Then
|
||||||
|
' Display a message if the condition is true
|
||||||
|
MsgBox "The number is greater than 10."
|
||||||
|
Else
|
||||||
|
' Display a message if the condition is false
|
||||||
|
MsgBox "The number is not greater than 10."
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
h6 { font-size: 18px; }
|
||||||
|
</style>
|
||||||
|
|
||||||
|
### VBA - Helloworld Example 1/2
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Sub HelloWorld()
|
||||||
|
' Display a message box with "Hello, World!"
|
||||||
|
MsgBox "Hello, World!"
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub TestHelloWorld()
|
||||||
|
' Call the HelloWorld subroutine
|
||||||
|
HelloWorld
|
||||||
|
End Sub
|
||||||
|
```
|
||||||
|
|
||||||
|
###### Note to Louis: show debug, show run
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Helloworld Example 2/2
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# VBA - Q n A / Thank you
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
<!--
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Procedures
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Procedures
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Procedures
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Procedures
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Procedures
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Procedures
|
||||||
|
```
|
||||||
|
|
||||||
|
--- -->
|
BIN
wenarama/slides_01/excel-vba.pdf
Normal file
BIN
wenarama/slides_01/images/backdrop_00.jpg
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/backdrop_01.jpg
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/backdrop_02.jpg
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/backdrop_03.jpg
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/backdrop_04.jpg
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/backdrop_05.jpg
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/backdrop_06.jpg
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/backdrop_07.jpg
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/backdrop_08.jpg
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/backdrop_09.jpg
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/excel.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/thank_you.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/vba-button.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/vba-debug-menu.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/vba-developer-tab.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/vba-enable-developer-menu-1.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/vba-enable-developer-menu-2.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/vba-enable-macro.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/vba-file-menu.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/vba-helloworld-run.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/vba-ide.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/vba-module-menu.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/vba-module.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/vba-run-menu.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/vba-save-as-xlsm.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/vba-save-with-macro.png
(Stored with Git LFS)
Normal file
BIN
wenarama/slides_01/images/vba-start.png
(Stored with Git LFS)
Normal file
344
wenarama/slides_01/index.html
Normal file
BIN
wenarama/slides_01/index.pdf
Normal file
3715
wenarama/slides_01/package-lock.json
generated
Normal file
21
wenarama/slides_01/package.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "slides",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"ren_html": "marp slide-deck.md -o index.html",
|
||||||
|
"ren_pdf": "marp --allow-local-files --pdf-notes slide-deck.md -o index.pdf",
|
||||||
|
"gitUpdate":"git add . && git commit -m'update,'"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"@marp-team/marp-cli": "^3.3.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"live-server": "^1.2.2"
|
||||||
|
}
|
||||||
|
}
|
400
wenarama/slides_01/slide-deck.md
Normal file
@@ -0,0 +1,400 @@
|
|||||||
|
---
|
||||||
|
theme: gaia
|
||||||
|
_class: lead
|
||||||
|
paginate: true
|
||||||
|
backgroundColor: #fff
|
||||||
|
backgroundImage: url('./images/backdrop_09.jpg')
|
||||||
|
---
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
# **Excel VBA**
|
||||||
|
|
||||||
|
Excel VBA introduction
|
||||||
|
|
||||||
|
https://louiscklaw.github.io/
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA IDE
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Enable VBA IDE 1/2
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA Start IDE
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Save with macro enabled workbook 1/2
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Save with macro enabled workbook 2/2
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - File menu
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
<!-- "run", "interrupt", "break point" -->
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Run menu
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
<!-- "run", "interrupt", "break point" -->
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Debug menu
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
<!-- "step into", "step over" -->
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Module
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA looping - For loop 1/2
|
||||||
|
|
||||||
|
```VB
|
||||||
|
For counter = start To end [Step stepcount]
|
||||||
|
[statement 1]
|
||||||
|
....
|
||||||
|
[statement n]
|
||||||
|
[Exit For]
|
||||||
|
[statement 11]
|
||||||
|
....
|
||||||
|
[statement n]
|
||||||
|
Next
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- please draft me a sample of VBA for loop -->
|
||||||
|
|
||||||
|
### VBA looping - For loop 2/2
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Sub ForLoopExample()
|
||||||
|
Dim i As Integer
|
||||||
|
|
||||||
|
' Loop from 1 to 5
|
||||||
|
For i = 1 To 5
|
||||||
|
' Print the value of i
|
||||||
|
Debug.Print i
|
||||||
|
Next i
|
||||||
|
|
||||||
|
' Loop from 10 to 1 with a step of -1
|
||||||
|
For i = 10 To 1 Step -1
|
||||||
|
' Print the value of i
|
||||||
|
Debug.Print i
|
||||||
|
Next i
|
||||||
|
End Sub
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA looping - While loop 1/2
|
||||||
|
|
||||||
|
```
|
||||||
|
While condition(s)
|
||||||
|
[statements 1]
|
||||||
|
[statements 2]
|
||||||
|
...
|
||||||
|
[statements n]
|
||||||
|
Wend
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- please draft me a sample of VBA while loop -->
|
||||||
|
|
||||||
|
### VBA looping - While loop 2/2
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Sub WhileLoopExample()
|
||||||
|
Dim i As Integer
|
||||||
|
|
||||||
|
' Loop while i is less than or equal to 5
|
||||||
|
i = 1
|
||||||
|
While i <= 5
|
||||||
|
' Print the value of i
|
||||||
|
Debug.Print i
|
||||||
|
|
||||||
|
' Increment i by 1
|
||||||
|
i = i + 1
|
||||||
|
Wend
|
||||||
|
|
||||||
|
' Loop while i is greater than 0
|
||||||
|
i = 10
|
||||||
|
Do While i > 0
|
||||||
|
' Print the value of i
|
||||||
|
Debug.Print i
|
||||||
|
|
||||||
|
' Decrement i by 1
|
||||||
|
i = i - 1
|
||||||
|
Loop
|
||||||
|
End Sub
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Functions 1/2
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Function Functionname(parameter-list)
|
||||||
|
statement 1
|
||||||
|
.......
|
||||||
|
statement n
|
||||||
|
End Function
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- please draft me a sample of VBA function -->
|
||||||
|
|
||||||
|
### VBA - Functions 2/2
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Function AddNumbers(num1 As Double, num2 As Double) As Double
|
||||||
|
' Add two numbers and return the result
|
||||||
|
AddNumbers = num1 + num2
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Sub TestAddNumbers()
|
||||||
|
Dim result As Double
|
||||||
|
|
||||||
|
' Call the AddNumbers function and store the result in the 'result' variable
|
||||||
|
result = AddNumbers(5.5, 3.2)
|
||||||
|
|
||||||
|
' Display the result
|
||||||
|
MsgBox "The result is: " & result
|
||||||
|
End Sub
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- please draft me a sample of VBA Sub -->
|
||||||
|
|
||||||
|
### VBA - Subs 1/2
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Sub Area(x As Double, y As Double)
|
||||||
|
MsgBox x * y
|
||||||
|
End Sub
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- please draft me a sample of VBA Sub -->
|
||||||
|
|
||||||
|
### VBA - Subs 2/2
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Sub GreetUser(name As String)
|
||||||
|
' Display a greeting message with the provided name
|
||||||
|
MsgBox "Hello, " & name & "! Welcome to our program."
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub TestGreetUser()
|
||||||
|
' Call the GreetUser subroutine and pass a name
|
||||||
|
GreetUser "John"
|
||||||
|
End Sub
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Message Box
|
||||||
|
|
||||||
|
```VB
|
||||||
|
MsgBox(prompt[,buttons][,title][,helpfile,context])
|
||||||
|
```
|
||||||
|
|
||||||
|
TODO: screen capture of Msgbox
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Constants
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Const MyInteger As Integer = 42
|
||||||
|
Const myDate As Date = #2/2/2020#
|
||||||
|
Const myDay As String = "Sunday"
|
||||||
|
```
|
||||||
|
|
||||||
|
### VBA - Variables
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Dim MyInteger As Integer = 42
|
||||||
|
Dim myDate As Date = #2/2/2020#
|
||||||
|
Dim myDay As String = "Sunday"
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Arithmatic Operators
|
||||||
|
|
||||||
|
let A = 5, B = 10
|
||||||
|
|
||||||
|
| sign | means/equals |
|
||||||
|
| ---- | ---------------------- |
|
||||||
|
| \+ | A + B will give 15 |
|
||||||
|
| \- | A - B will give -5 |
|
||||||
|
| \* | A \* B will give 50 |
|
||||||
|
| / | B / A will give 2 |
|
||||||
|
| Mod | B Mod A will give 0 |
|
||||||
|
| ^ | B ^ A will give 100000 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Comparison Operators
|
||||||
|
|
||||||
|
let A = 5, B = 10
|
||||||
|
|
||||||
|
| sign | means/equals |
|
||||||
|
| ---- | ------------------ |
|
||||||
|
| = | (A = B) is False. |
|
||||||
|
| <> | (A <> B) is True. |
|
||||||
|
| \> | (A > B) is False. |
|
||||||
|
| < | (A < B) is True. |
|
||||||
|
| \>= | (A >= B) is False. |
|
||||||
|
| <= | (A <= B) is True. |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - If Statement 1/3
|
||||||
|
|
||||||
|
```VB
|
||||||
|
If(boolean_expression) Then
|
||||||
|
Statement 1
|
||||||
|
.....
|
||||||
|
.....
|
||||||
|
Statement n
|
||||||
|
End If
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - If Elseif - Else statement 2/3
|
||||||
|
|
||||||
|
```VB
|
||||||
|
If(boolean_expression) Then
|
||||||
|
Statement 1
|
||||||
|
.....
|
||||||
|
Statement n
|
||||||
|
ElseIf (boolean_expression) Then
|
||||||
|
Statement 1
|
||||||
|
.....
|
||||||
|
Statement n
|
||||||
|
ElseIf (boolean_expression) Then
|
||||||
|
Statement 1
|
||||||
|
.....
|
||||||
|
Statement n
|
||||||
|
Else
|
||||||
|
Statement 1
|
||||||
|
.....
|
||||||
|
Statement n
|
||||||
|
End If
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - If statement example 3/3
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Sub CheckNumber(number As Integer)
|
||||||
|
' Check if the number is greater than 10
|
||||||
|
If number > 10 Then
|
||||||
|
' Display a message if the condition is true
|
||||||
|
MsgBox "The number is greater than 10."
|
||||||
|
Else
|
||||||
|
' Display a message if the condition is false
|
||||||
|
MsgBox "The number is not greater than 10."
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
h6 { font-size: 18px; }
|
||||||
|
</style>
|
||||||
|
|
||||||
|
### VBA - Helloworld Example 1/2
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Sub HelloWorld()
|
||||||
|
' Display a message box with "Hello, World!"
|
||||||
|
MsgBox "Hello, World!"
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub TestHelloWorld()
|
||||||
|
' Call the HelloWorld subroutine
|
||||||
|
HelloWorld
|
||||||
|
End Sub
|
||||||
|
```
|
||||||
|
|
||||||
|
###### Note to Louis: show debug, show run
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Helloworld Example 2/2
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# VBA - Q n A / Thank you
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## <!--
|
||||||
|
|
||||||
|
### VBA - Procedures
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Procedures
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Procedures
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Procedures
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### VBA - Procedures
|
||||||
|
|
||||||
|
```VB
|
||||||
|
Procedures
|
||||||
|
```
|
||||||
|
|
||||||
|
--- -->
|