Blogtrottr
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中 
Manage your social media

Best social media tool for image publishing to Facebook and Twitter. Look amazing and delight your followers. Get 40% off when you sign up today.
From our sponsors
excel 巨集 迴圈條件問題
Oct 19th 2013, 16:31

練習了一個excel巨集 從台灣證券下載資料下來,
但會有幾個問題

1. 若我i 從 10到18, 跑到12將會出現錯誤 錯誤行為下:
.Refresh BackgroundQuery:=False
請問這是因為週末沒有網頁的關係? 有沒有辦法克服?

2. 因為網址月分跟日期十位數以下皆是以01, 02, ....,08,09表示
並非以1,2,3...表示
這樣我如何利用迴圈寫出i= 01, 02,....,08, 09, 10...,30
迴圈 i 的條件有什麼辦法可以克服這個問題?

巨集編碼如下:

Sub Macro1()

For i = 10 To 18
ActiveWorkbook.Worksheets.Add
ActiveSheet.Name = i

With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.twse.com.tw/ch/trading/exchange/BFIAMU/genpage/Report201310/201310" & i & "_F3_1_5.php" _
, Destination:=Range("$A$1"))
.Name = "201310" & i & "_F3_1_5"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "8"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Next i
End Sub

This entry passed through the Full-Text RSS service — if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers. Five Filters recommends:

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 gyyij7s6y6fly 的頭像
    gyyij7s6y6fly

    線上遊戲排行榜2013/2014,進擊的巨人線上看,candy crush saga外掛,正妹寫真三圍

    gyyij7s6y6fly 發表在 痞客邦 留言(0) 人氣()