→ soyoso:可能是with的問題,with是簡化陳述式為目的 04/04 12:09
→ soyoso:可否提供檔案 04/04 12:09
→ a777starmy:資料是公司內部資料檔案,可能不方便 >< 04/04 13:06
→ I4Lione:有 With 沒有 End With? 04/04 13:10
→ soyoso:那可以只貼巨集內容從sub..end sub 04/04 13:19
你看一下
Dim stocknumber As String '定義股票代號為字串
Dim startday As String
Dim endday As String
stocknumber = Cells(1, 2).Value '抓取儲存格B1的代號
startday = Cells(1, 4).Value
endday = Cells(1, 6).Value
Range("A3:F26").Select '顯示的範圍從A3到F26
Selection.ClearContents '清除A3到F26
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://money.hinet.net/z/z0/z00/z00a_" & stocknumber _ &
startday _ & endday _D.djhtm", Destination:= _
Range("$A$3"))
.Name = "z00a_2498_2012-1-1.djhtm"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "2"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
※ 編輯: a777starmy (114.33.66.62), 04/04/2014 13:49:18