[算表] excel 匯入判斷問題
軟體:excel
版本:2007
問題檔案
https://drive.google.com/open?id=0BwCgrQhGgaw7aHpkQkpYWDhoWnM
我有一段vba程式
是可以開啟檔案總館選擇csv檔案匯入
但我想要若是取消匯入的時候
可以中斷這個程式並跳出 已中斷
而且不會執行下面的clear動作
不知道要怎麼改
Sub 餘額檔匯入()
Worksheets("餘額檔").Activate
Dim ws As Worksheet, strFile As String, abc As String
Set ws = ActiveWorkbook.Sheets("餘額檔") '設定要輸進去的工作表名稱
strFile = Application.GetOpenFilename("Text Files (*.csv),*.csv", , "Please selec csv file...")
Sheets("餘額檔").Rows("3:100000").Select
Selection.ClearContents
Sheets("餘額檔").Columns("A:AB").Select
Selection.ClearContents
With ws.QueryTables.Add(Connection:="TEXT;" & strFile,
Destination:=ws.Range("A1"))
.TextFileParseType = xlDelimited
.TextFileCommaDelimiter = True
.Refresh
End With
abc = Sheets("餘額檔").Range("A1").End(xlDown).Row
Range("AC2:AQ2").Select
Selection.AutoFill Destination:=Range("AC2:AQ" & abc)
MsgBox "匯入完成"
End Sub
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.34.252.11
※ 文章網址: https://www.ptt.cc/bbs/Office/M.1485418496.A.E9B.html
※ 編輯: ptguitar (1.34.252.11), 01/26/2017 16:15:15
→
01/26 16:17, , 1F
01/26 16:17, 1F
→
01/27 02:09, , 2F
01/27 02:09, 2F
→
01/27 02:10, , 3F
01/27 02:10, 3F
→
01/27 02:10, , 4F
01/27 02:10, 4F
→
01/27 02:10, , 5F
01/27 02:10, 5F
→
01/27 07:07, , 6F
01/27 07:07, 6F
Office 近期熱門文章
PTT數位生活區 即時熱門文章