DEAR ALL 大大
1.使用圖一方式可將EXCEL內容傳至文字檔.若EXCEL資料10列
傳至文字檔後.第11列起.......都會傳空白
M= Sheet2.[A65536].End(xlUp).Row
For X = 1 To M
of.Write (Sheet2.Cells(X, 1) & Chr(13) & Chr(10))
Next
2.請教如何修改為 EXCEL 有幾列資料.傳至文字檔也僅有幾列資料.文字檔不要出現空白列之空白值
3.煩不吝賜教 THANKS*10000
圖一
Sub 傳送至文字檔()
Sheet2.Visible = True
Sheet1.Select
Range("A1").Select
If Sheet1.Range("c1") = "NG" Then
MsgBox "資料上限超過 5000筆-需與陳嵩豪確認"
End If
If Not (Sheet1.Range("c1") = "NG") Then
'組合檔案名稱
OutFile = "\\89.80.70.1\imp\" & Sheet2.Range("B1") & "-CB.pm.txt"
'建立檔案物件
Set fs = CreateObject("Scripting.FileSystemObject")
'開啟一個叫of的文字檔物件供輸出
On Error Resume Next
On Error GoTo 1
Set of = fs.CreateTextFile(OutFile, True)
'輸出標題至of
M = Sheet2.[A65536].End(xlUp).Row
For X = 1 To M
of.Write (Sheet2.Cells(X, 1) & Chr(13) & Chr(10))
Next
Sheet2.Select
Range("A1").Select
'關檔
of.Close
1: Sheet1.Select
Range("A1").Select
End If
End Sub作者: GBKEE 時間: 2017-11-2 10:08