我正在从 Microsoft Access 导入数据,错误检测似乎不起作用。如果代码尝试创建一个已经存在的工作表,请继续并将目标工作表设置为已经存在的工作表。任何提示将不胜感激。
For ix = stWW To edWW
For modi = 0 To mdcnt - 1
On Error Resume Next
Sheets.Add(After:=Sheets(Sheets.Count)).Name = ix & " " & modvar(modi)
On Error GoTo 0
Set DestinationSheet = Worksheets(ix & " " & modvar(modi))
'strSQL2 = "SELECT 1302_Scan.* FROM 1302_Scan;"
strSQL = "SELECT " & ix & "_" & modvar(modi) & ".* FROM " & ix & "_" & modvar(modi) & ";"
'MsgBox strSQL & "|" & strSQL
DestinationSheet.Cells.Clear
之前在代码中使用过,可能会导致@sous2817 的建议出错。
On Error GoTo continue
Do While Not IsNull(modvar(ii))
mdcnt = mdcnt + 1
ii = ii + 1
Loop
continue:
On Error GoTo 0