0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

エクセルマクロ(VBA)入門編その2変数・繰返し処理

Posted at

はじめに

Excelマクロ(VBA)を使いこなせば、様々な業務が効率化されます。
今回は、入門編その2と題して、変数や繰り返し処理について、ご紹介します。
尚、主な操作はYoutubeの動画をご覧頂き、完成したプログラムを、以下にご紹介しています。

環境

Windows10
Microsoft365バージョンのExcel

解説の流れ:

・セルの情報取得とセット
・変数について
・Forループによる繰返し処理
・表の最終行取得方法

YouTubeでの解説:

上記の作業の流れをYoutubeで詳しく解説していますので、ぜひ、ご覧ください。

サンプルソース

YouTubeで紹介している処理のプログラムソースです。

練習2
Sub 練習2()

    Y = 0
    Last_ROW = Range("A" & Rows.Count).End(xlUp).Row
        
    For I = 2 To Last_ROW
        X = Range("C" & I).Value
        Y = Y + X
        ' MsgBox ("X=" & X & " Y=" & Y)
        
    Next I
    Range("F2").Value = Y
    
End Sub

最後に:

今回は、エクセルマクロの入門編2ということで、徐々にプログラムらしくはなってきました。
ただ、これだけでは、エクセル関数の方が簡単です。
今後、徐々にレベルアップして、最終的には業務に役立つプログラムもご紹介していきたいと思います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?