[算表] VBA On Error Resume Next
軟體:excel
版本:2016
大家好 目前看書自學VBA中
書本中範例要把其中一欄的名稱,逐一新增成工作表名稱並不重複
Sub test()
Dim i As Integer, sht As Worksheet
Set sht = Worksheets("工作表21")
i = 2
Do While sht.Cells(i, "C") <> ""
On Error Resume Next
If Worksheets(sht.Cells(i, "C").Value) Is Nothing Then
Worksheets.Add after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = sht.Cells(i, "C").Value
End If
i = i + 1
Loop
End Sub
其中加入了On Error Resume Next,估狗了一下這個指令是忽略錯誤繼續執行
當我拿掉這行指令事就無法執行程序了,代表
If Worksheets(sht.Cells(i, "C").Value) Is Nothing Then
有問題嗎?可是我看不出問題在哪,想問為啥差這個指令差這麼多,還有上面那行錯在哪
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.143.15.249
※ 文章網址: https://www.ptt.cc/bbs/Office/M.1513601571.A.79D.html
→
12/18 23:28,
8年前
, 1F
12/18 23:28, 1F
→
12/18 23:33,
8年前
, 2F
12/18 23:33, 2F
→
12/18 23:38,
8年前
, 3F
12/18 23:38, 3F
→
12/18 23:38,
8年前
, 4F
12/18 23:38, 4F
→
12/18 23:38,
8年前
, 5F
12/18 23:38, 5F
→
12/19 09:45,
8年前
, 6F
12/19 09:45, 6F
→
12/19 09:46,
8年前
, 7F
12/19 09:46, 7F
→
12/19 09:57,
8年前
, 8F
12/19 09:57, 8F
→
12/19 09:57,
8年前
, 9F
12/19 09:57, 9F
→
12/19 10:12,
8年前
, 10F
12/19 10:12, 10F
→
12/19 10:14,
8年前
, 11F
12/19 10:14, 11F
→
12/19 10:15,
8年前
, 12F
12/19 10:15, 12F
※ 編輯: zzatr (218.173.0.192), 12/21/2017 16:16:50
Office 近期熱門文章
PTT數位生活區 即時熱門文章