|
|
| Excel VBA Macro ・ フロー制御 ・ FAQ |
|
存在しないシートを参照してもエラーを出したくないが?
|
|
|
|
Question 64.9 |
Excel VBA Borad (掲示板)より |
 |
 |
|
|
参照先のシートが "存在しない"時はエラーが出て、デバッグに強制的に入ってしまいます。
そうではなくメッセージボックスを出して、シートを作りなさい、と注意を促すだけにしたいのです。(デバッグモードに入りたくない)
if sheets("sheet4")=nothing then goto... としましたがだめで
if sheets("sheet4")=enpty then goto... でもだめです。
|
|
|
Dim mySht As Worksheet
On Error Resume Next
Set mySht = Worksheets("Sheet4")
On Error GoTo 0
If mySht Is Nothing Then
MsgBox "シートを作りなさい"
Exit Sub
End If
といった感じです。 はずしてたらすみません。
|
|
|
|
| |
|
|