[算表] EXCEL可以利用巨集改網址的日期嗎??
因為要用外部資料連結抓一些資料進來excel
但每天日期都會變,巨集有辦法設定好日期
然後自動修改外部資料連結的網址日期嗎??
例如: 外部資料連結的網址如下
A = Cells(1, 2).Value '抓取儲存格B1的代號
B = Cells(1, 4).Value
C = Cells(1, 6).Value
Range("A3:F26").Select '顯示的範圍從A3到F26
Selection.ClearContents '清除A3到F26
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://ptt.cc"&
A_B_C & "_D.djhtm", Destination:= _
我黃色這段語法錯誤,不知如何修改??
簡單的覆製、貼上巨集我會,但突然沒有idea如何去設定日期來製作巨集
可以給我一些idea嗎??
3Q
--
一個年輕人問一個老人:「智慧從哪裡來?」 老人回答說:「精確的判斷力。」
年輕人又接著問老人:「那麼精確的判斷力從哪裡來?」 老人又接著回答說:「靠經驗。」
年輕人再問老人:「經驗哪裡來?」 老人說:「錯誤的判斷力。」
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.33.66.62
※ 文章網址: http://www.ptt.cc/bbs/Office/M.1396543089.A.317.html
※ 編輯: a777starmy (114.33.66.62), 04/04/2014 03:09:42
→
04/04 12:09, , 1F
04/04 12:09, 1F
→
04/04 12:09, , 2F
04/04 12:09, 2F
→
04/04 13:06, , 3F
04/04 13:06, 3F
→
04/04 13:10, , 4F
04/04 13:10, 4F
→
04/04 13:19, , 5F
04/04 13:19, 5F
你看一下
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
→
04/04 14:41, , 6F
04/04 14:41, 6F