티스토리 뷰

해당 시트명이 없으면 sub 종료하는 로직

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Sub main()
    If sheetExists("raw_data"= False Then
        MsgBox ("raw_data 시트가 없습니다.")
        Exit Sub
    End If
 
End Sub
 
Function sheetExists(shtName As String, Optional wb As Workbook) As Boolean
    Dim sht As Worksheet
 
     If wb Is Nothing Then Set wb = ThisWorkbook
     On Error Resume Next
     Set sht = wb.Sheets(shtName)
     On Error GoTo 0
     sheetExists = Not sht Is Nothing
 End Function
cs


raw_data라는 시트가 없으면 종료한다.


시트명 출력하는 로직

1
2
3
4
5
Sub 시트명뿌리기()
    For Each sh In ActiveWorkbook.Worksheets
        Debug.Print (sh.Name)
    Next
End Sub
cs


공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/03   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
글 보관함