返回列表 上一主題 發帖

Excel 2010 轉置txt檔求助

本帖最後由 luhpro 於 2013-6-30 22:28 編輯

回復 1# kulisung
關於讀檔的程式這裡就不贅述了,
僅提供自己想的資料存放位置處理方式: (d(lpos) 是利用 Dictionary 來索引該資料存放的欄位)

讀檔...
lrow = 2 ' 列 1 為標題列
icol = 1 ' 資料從第 1 欄開始放, 假設每筆資料 Title 文字都相同
sStr = 讀取的一筆資料內容

Do While EOF(1)
  Do While Left(sStr, 5) <> "-----"
   lpos = InStr(1, sStr, ":")
    stitle = Trim(Left(sStr, lpos - 2))
    If d(lpos) = "" Then
      Cells(1, icol) = stitle
      icol = icol + 1
    End If
    sData = Trim(Mid(sStr, lpos + 2, Len(sStr) - lpos))
    sStr = 讀取的一筆資料內容
  Loop
  lrow = lrow + 1
Loop

' 關檔

TOP

        靜思自在 : 人要自愛,才能愛普天下的人。
返回列表 上一主題