LoginSignup
1
2

More than 5 years have passed since last update.

VBAでファイルの読み込みとシート数の取得のサンプル

Last updated at Posted at 2016-03-19

自分でよく使用する書き方のメモ

VBA
Sub main()
    Set st = ActiveSheet
    row_max = st.Range("a1").SpecialCells(xlLastCell).Row

    ' 2行目から処理を開始する
    For i = 2 To row_max
        Application.ScreenUpdating = False

        ' 処理済みの判断
        If st.Range("A" & i) <> 1 Then
            GoTo Continue:
        End If

        ' Excelを開く
        Set wb = Workbooks.Open(st.Range("B" & i))
        wb.Close SaveChanges:=False

        ' 完了済み
        st.Range("A" & i) = 0

        Application.ScreenUpdating = False
Continue:
        ActiveWindow.ScrollRow = i
        ActiveWindow.ScrollColumn = 1
    Next i
End Sub

1
2
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
1
2