|
Sub 生成txt()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim ar As Variant
Dim br()
ar = Range("a4:r7")
mc = ActiveSheet.Name
ReDim br(1 To 7, 1 To 1)
For j = 5 To UBound(ar, 2) - 1 Step 2
If ar(1, j) <> "" Then
n = n + 1
If ar(4, j) = "" Then ar(4, j) = 0
br(n, 1) = ar(1, j) & ar(2, j) & ar(4, j) & "," & ar(2, j + 1) & ar(4, j + 1)
End If
Next j
Application.SheetsInNewWorkbook = 1
Set wb = Workbooks.Add
With wb.Worksheets(1)
.[a1].Resize(n, 1) = br
End With
wb.SaveAs Filename:=ThisWorkbook.Path & "\" & mc & ".txt", _
FileFormat:=xlUnicodeText, CreateBackup:=False
wb.Close
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox "ok!"
End Sub
|
|