- ©«¤l
- 835
- ¥DÃD
- 6
- ºëµØ
- 0
- ¿n¤À
- 915
- ÂI¦W
- 16
- §@·~¨t²Î
- Win 10,7
- ³nÅ骩¥»
- 2019,2013,2003
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2010-5-3
- ³Ì«áµn¿ý
- 2024-11-14
|
¦^´_ 1# alexsas38
¥un¦b .Cells.ClearContents ¤U¤è¥[¤W :
.Columns(2).NumberFormat = "@" <- ¸Ñ¨M 0 ®ø¥¢ªº°ÝÃD(±NÀx¦s®æ®æ¦¡³]¬° "¤å¦r")
µM«á¦bµ{¦¡¶}ÀY¥[¤W :
Dim lRow As Long, lI As Long
±µµÛ¦b .Cells.QueryTable.Delete ¤U¤è¥[¤W :
lRow = .Cells(Rows.Count, 1).End(xlUp).Row
For lI = 1 To lRow
If Right(.Cells(lI, 1), 1) = "(" Then .Cells(lI, 2) = .Cells(lI, 1) & " " & .Cells(lI, 2) & " " & .Cells(lI, 3): .Cells(lI, 1) = "": .Cells(lI, 3) = ""
If .Cells(lI, 3) <> "" Then .Cells(lI, 2) = .Cells(lI, 2) & " " & .Cells(lI, 3) & " " & .Cells(lI, 4): .Cells(lI, 3) = "": .Cells(lI, 4) = ""
Next lI <- ¬JµMµ{¦¡·|©î¶}ì¥ýªº¤å¦r ¨º»ò¦A¨Ì·Ó¨ä³W«h§â¸Ó¦X¨Öªº¦X¨Ö°_¨Ó´NOK¤F)
§Y¥i.- Sub importtxt()
- Dim path, folder, fname
- Dim lRow As Long, lI As Long
-
- With Workbooks.Add '¼ÐÃD¦C
- .Sheets(1).Range("A1:H1") = Array("Àç·~¤H²Î¤@½s¸¹", "t³d¤H©m¦W", "Àç·~¤H¦WºÙ", "Àç·~¡]µ|Äy¡^µn°O¦a§}", "¸ê¥»ÃB(¤¸)", "²Õ´ºØÃþ", "³]¥ß¤é´Á", "µn°OÀç·~¶µ¥Ø")
- '·s¼W¼È¦s¸ê®Æªí
- With .Sheets.Add(after:=.Sheets(.Sheets.Count))
- 'ÂsÄý¿ï¾Ü¸ê®Æ§¨
- With Application.FileDialog(msoFileDialogFolderPicker)
- .AllowMultiSelect = False
- If .Show = -1 Then path = .SelectedItems(1) & "\"
- End With
- '¹ï©Ò¦³¸Ó¸ê®Æ§¨¤Uªºtxt³B²z
- folder = Dir(path & "*.txt")
- Do While folder <> ""
- .Cells.ClearContents
- .Columns(2).NumberFormat = "@"
-
- '¶×¤J¥~³¡¸ê®Æ
- With .QueryTables.Add(Connection:="TEXT;" & path & folder, Destination:=.Range("A1"))
- .Name = "¸ê®Æ"
- .RefreshPeriod = 0
- .TextFileSpaceDelimiter = True 'ªÅ¥ÕÁ䬰¤À³Î¦r¤¸
- .Refresh BackgroundQuery:=False
- End With
- '§R°£¸ê®Æ³s½u
- .Cells.QueryTable.Delete
-
- lRow = .Cells(Rows.Count, 1).End(xlUp).Row
- For lI = 1 To lRow
- If Right(.Cells(lI, 1), 1) = "(" Then .Cells(lI, 2) = .Cells(lI, 1) & " " & .Cells(lI, 2) & " " & .Cells(lI, 3): .Cells(lI, 1) = "": .Cells(lI, 3) = ""
- If .Cells(lI, 3) <> "" Then .Cells(lI, 2) = .Cells(lI, 2) & " " & .Cells(lI, 3) & " " & .Cells(lI, 4): .Cells(lI, 3) = "": .Cells(lI, 4) = ""
- Next lI
- '·s¼W¸ê®Æ¨ì²Ä¤@Ó¤u§@ªí
- .Parent.Sheets(1).Cells(.Rows.Count, "A").End(xlUp).Offset(1).Resize(, 8).Value = Application.Transpose(.Range("B1:B8").Value)
- folder = Dir
- Loop
- '§R°£¼È¦s¸ê®Æªí,¤£Åã¥Üĵ§iµøµ¡
- Application.DisplayAlerts = False
- .Delete
- Application.DisplayAlerts = True
- End With
- .Sheets(1).Activate '¨Ï¶}±Ò¸ÓÀɮɪ½±µ¨ì²Ä¤@Ó¤u§@ªí
- '¦sÀÉ
- fname = Application.GetSaveAsFilename(InitialFileName:=path & "final.xls", FileFilter:="Excel Files (*.xls),*.xls", Title:="Àx¦sÀÉ®×")
- '°£«D«ö¨ú®ø, §_«h¦sÀÉ
- If TypeName(fname) = "String" Then .SaveAs Filename:=fname, FileFormat:=xlExcel8
- End With
- End Sub
½Æ»s¥N½X |
|