|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
请问美女楼主,模块1里面的三个过程用途是什么?本人初学者,看不懂哎
Sub NewTxt()
' Dim Arr, k%, Str1$
Arr = Range("e2", [A65536].End(3)(2, 7))
' Arr = Range("a2", "k2")
For k = 1 To UBound(Arr)
'Str = Str & vbLf & Join(Application.Index(Arr, k), " ") & vbCr
' Str1 = Str1 & vbLf & Join(Application.Index(Arr, k), ",")
Str1 = Str1 & vbCrLf & Join(Application.Index(Arr, k), ",")
Next
Open ThisWorkbook.Path & "\退休.txt" For Output As #1
Print #1, Str1
Reset
End Sub
Sub test()
Dim ws As Worksheet
Dim rng As Range
For Each ws In ThisWorkbook.Worksheets
Set rng = ws.UsedRange
Dim r As Range, rr As Range, s$
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("d:\" & ws.Name & ".csv", True)
For Each r In rng.Rows
s = ""
For Each rr In r.Cells
s = s & rr.Value & ","
Next
a.writeline (s)
Next
a.Close
Next
End Sub
Sub NewCsv()
Dim Sh As Worksheet
Application.SheetsInNewWorkbook = 1
Application.DisplayAlerts = False
For Each Sh In Sheets
Sh.UsedRange.Copy Workbooks.Add.ActiveSheet.[a1]
ActiveWorkbook.SaveAs "D:\" & Sh.Name & ".txt", FileFormat:=xlText, CreateBackup:=False
ActiveWorkbook.Close
Next
Application.DisplayAlerts = True
Application.SheetsInNewWorkbook = 3
End Sub
|
|