[算表] EXCEL可以利用巨集改網址的日期嗎??

看板Office作者 (呼力贏大師(大輸))時間10年前 (2014/04/04 00:38), 10年前編輯推噓0(006)
留言6則, 3人參與, 最新討論串1/1
因為要用外部資料連結抓一些資料進來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
可能是with的問題,with是簡化陳述式為目的
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
有 With 沒有 End With?
04/04 13:10, 4F

04/04 13:19, , 5F
那可以只貼巨集內容從sub..end sub
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
文章代碼(AID): #1JFOvnCN (Office)