close
2058 |
Excel VBA 如何檢查工作表(名稱)是否存在 |
||||
實用性 |
●○○ |
難易度 |
●○○○ |
範本檔 |
2058.XLSX |
這個問題很感謝PCW這位專家的解答,內容如下:
Sub check_sht_names()
dim shtNames as string, shtArray as variant
dim sht as worksheet, pos as variant
' get all names of worksheets
for each sht in worksheets
shtNames = shtNames & "/" & sht.name
next sht
shtNames = Mid(shtNames, 2)
' make a list of worksheet names
shtArray = Split(shtNames, "/")
Rcnt = Worksheets("AA").Range("G6").End(xlDown).Row
For i = 7 To Rcnt
ShtN = Worksheets("AA").Range("G" & i).Value
pos = Application.Match(ShtN, shtArray, 0)
If IsError(pos) Then
With orksheets.Add(after:=worksheets(worksheets.count))
.Name = ShtN
End With
end if
Next i
End Sub
文章標籤
全站熱搜
留言列表