59日目:Excel マクロ/VBA
Excel マクロ/VBAの講義3日目。 講義の合間に、MOS Excel Expert(第2回模擬試験)。
【講義内容】
- Chapter4 変数と制御構文
【ワンポイント】
スコープ
module1
Dim scope As String Public pScope As String
Sub Proc1() scope = "Module1 - Proc1" MsgBox scope End Sub
Sub Proc2() Dim scope As String scope = "Proc2" MsgBox scope MsgBox Module1.scope End Sub
Sub Main() Proc1 Proc2 Module2.Main End Sub
module2
Sub Main() Proc3 Proc4 End Sub
Sub Proc3() pScope = "Module2 - Proc3" MsgBox pScope End Sub
Private Sub Proc4() MsgBox scope pScope = "Module2 - Proc4" MsgBox pScope End Sub
名前の範囲でループ処理(for each)
Sub getItems() Dim items As Range For Each items In Range("商品名") MsgBox (items.Value) Next End Sub
【今日の積み上げ】
・Excel マクロ基本操作