Muni Bus

パソコンの操作方法や設定方法を忘れないようにメモしています。ブログを一回引っ越ししているので、所々表示がかなり乱れています・・・

ブックの中にワークシートがあるかどうか調べる

Excel VBAで,ワークシートがブック内にあるかどうかを調べる関数です.
Function ExistWS(wsname As String) As Boolean
    Dim ws As Worksheet
    Dim bn As Boolean
    bn = False
    For Each ws In Worksheets
        If ws.Name = wsname Then
            bn = True
            Exit For
        End If
    Next ws
    ExistWS = bn
End Function
例えばExistWS("Sheet1")として,Sheet1というワークシートがあればTrueを返します.
Apple iPod shuffle 1GB シルバー MB225J/A Apple iPod shuffle 1GB シルバー MB225J/A