返回列表 上一主題 發帖

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

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

請問是否可以透過不同日期儲存格的文字作為路徑,每天匯入不同的檔案呢
  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
複製代碼

匯入外部資料.rar (17.23 KB)

        靜思自在 : 願要大、志要堅、氣要柔、心要細。
返回列表 上一主題