1
1

More than 5 years have passed since last update.

シート名の存在チェック

Posted at

シートをVBA上でコピーや移動をする時
同名のシート名があるとエラーで中断してしまいますので
その前で、シート名が存在するかチェックする関数を作りました。
第一引数はシート名です。
Booleanで返却します。

シート名の存在チェック
Public Function checkSheetName(checkName As String) As Boolean

    Dim sheetObject As Object

    checkSheetName = False

    For Each sheetObject In ActiveWorkbook.Sheets
        If sheetObject.Name = checkName Then
            checkSheetName = True
            Exit For
        End If
    Next sheetObject

End Function
1
1
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
1