Board logo

標題: [發問] 請教如何透過每天日期與儲存格文字來匯入外部資料呢 [打印本頁]

作者: dreamsway    時間: 2018-10-12 11:17     標題: 請教如何透過每天日期與儲存格文字來匯入外部資料呢

請問是否可以透過不同日期與儲存格的文字作為路徑,每天匯入不同的檔案呢
  1. Sub 匯入外部資料()
  2. Dim datecode As String '定義datacode為日期字串
  3. Dim futures As String '定義futures為商品代號 其文字來源在Cells(2, "L")

  4. y = Year(Now)
  5. m = Month(Now)
  6. d = Day(Now)
  7. datecode = y & m & d
  8. futures = Cells(2, "L") '試著把下方的日期與代碼改成定義的變數 卻無法作用
  9. With ActiveSheet.QueryTables.Add(Connection:= _
  10.         "TEXT;D:\data\datecode\futures\datecode_Match.txt", Destination:=Range("$A$2"))
  11.         .Name = "datecode_Match"
  12. End Sub
複製代碼





歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)