[英]Excel- Export specific columns to multiple text files vba
我的excel文件是這樣的
new_filename MEDIA_ID SIGHTING_ID FRAME FACE_X FACE_Y FACE_WIDTH
28069_00000.png 28069 15775 0 309.715 16.714 141
28069_00060.png 28069 15776 60 318 17 136.57
28069_00075.png 28069 15777 75 325.857 18 138.571
28069_00135.png 28069 15778 135 343.428 30.5757 134.1428
28069_00195.png 28069 15779 195 323.333 18 155.333
28069_00255.png 28069 15780 255 278.243 15.2857 138
28069_00315.png 28069 15781 315 284 18.8 137.85
我想從某些列中提取值,例如 facex、facey、face width 和 face height,並將提取的值保存在一個文本文件中,該文本文件將新文件名列中的值作為文本文件的名稱。
我想對近 3000 行重復相同的過程。
所以 txt 文件 1 的值應該是 (2,c6) (2,c7) (2,c8) 並且它應該被命名為 (2,c1) 等所有行。 夠清楚了嗎?
Sub Test()
Dim r As Long
With ActiveSheet
r = 2
Do While .Cells(r, 1).Value <> ""
Open .Parent.Path & "\" & Left(.Cells(r, 1).Value, Len(.Cells(r, 1).Value) - 4) & ".TXT" For Output As #1
Print #1, .Cells(r, 6).Value & "," & .Cells(r, 7).Value & "," & .Cells(r, 8).Value
Close #1
r = r + 1
Loop
End With
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.