|
参考代码
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim MyPath As String, MyFile, ThisBK, MyArr, s$
ThisBK = ActiveWorkbook.Name
MyPath = ThisWorkbook.Path & "\"
MyFile = Dir(MyPath & "*.xls*")
Do While MyFile > ""
If MyFile <> ThisBK Then
Workbooks.Open Filename:=MyPath & MyFile
Set c = ActiveWorkbook
MyArr = c.Sheets("Sheet1").Range("A1").CurrentRegion
s = "#Depth ZS QL C1 C2 C3 IC4 NC4 NC5 IC5"
For i = 2 To UBound(MyArr)
s = s & vbCrLf & MyArr(i, 2) & vbTab & _
Format(MyArr(i, 3), "0.0000") & vbTab & _
Format(MyArr(i, 4), "0.0000") & vbTab & _
Format(MyArr(i, 5), "0.0000") & vbTab & _
Format(MyArr(i, 6), "0.0000") & vbTab & _
Format(MyArr(i, 7), "0.0000") & vbTab & _
Format(MyArr(i, 8), "0.0000") & vbTab & _
Format(MyArr(i, 9), "0.0000") & vbTab & _
Format(MyArr(i, 10), "0.0000") & vbTab & _
Format(MyArr(i, 11), "0.0000")
Next i
Open MyPath & Split(c.Name, ".")(0) & ".txt" For Output As #1
Print #1, s
Close #1
c.Close False
End If
MyFile = Dir
Loop
Application.ScreenUpdating = True
End Sub
|
|