Skip i'r prif gynnwys

Sut i fewnforio ffeiliau testun lluosog i ddalenni lluosog?

Gan dybio, mae yna nifer o ffeiliau testun mewn ffolder o'ch cyfrifiadur, nawr, rydych chi am fewnforio'r ffeiliau testun hyn i lyfr gwaith Excel, a gosod pob ffeil testun mewn taflenni gwaith ar wahân. Bydd copïo a gludo pob ffeil testun i'r daflen waith fesul un yn gwastraffu llawer o amser, yma, gallaf siarad am rai triciau i chi ddatrys y broblem hon.

Mewngludo ffeiliau testun lluosog i wahanu taflenni gwaith gyda chod VBA

Rhannwch lyfr gwaith i ffeiliau testun / pdf / csv / xlsx lluosog ar wahân gyda Kutools ar gyfer Excel


swigen dde glas saeth Mewngludo ffeiliau testun lluosog i wahanu taflenni gwaith gyda chod VBA

Efallai y bydd y cod VBA canlynol yn eich helpu i fewnforio pob ffeil testun i daflenni ar wahân mewn llyfr gwaith newydd ar unwaith, gwnewch fel a ganlyn:

1. Daliwch i lawr y ALT + F11 allweddi yn Excel i agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

2. Cliciwch Mewnosod > Modiwlau, a gludwch y cod canlynol yn y Modiwlau Ffenestr.

Cod VBA: Mewnforio ffeiliau testun lluosog i daflenni gwaith ar wahân:

Sub CombineTextFiles()
'updateby Extendoffice
    Dim xFilesToOpen As Variant
    Dim I As Integer
    Dim xWb As Workbook
    Dim xTempWb As Workbook
    Dim xDelimiter As String
    Dim xScreen As Boolean
    On Error GoTo ErrHandler
    xScreen = Application.ScreenUpdating
    Application.ScreenUpdating = False
    xDelimiter = "|"
    xFilesToOpen = Application.GetOpenFilename("Text Files (*.txt), *.txt", , "Kutools for Excel", , True)
    If TypeName(xFilesToOpen) = "Boolean" Then
        MsgBox "No files were selected", , "Kutools for Excel"
        GoTo ExitHandler
    End If
    I = 1
    Set xTempWb = Workbooks.Open(xFilesToOpen(I))
    xTempWb.Sheets(1).Copy
    Set xWb = Application.ActiveWorkbook
    xTempWb.Close False
    xWb.Worksheets(I).Columns("A:A").TextToColumns _
      Destination:=Range("A1"), DataType:=xlDelimited, _
      TextQualifier:=xlDoubleQuote, _
      ConsecutiveDelimiter:=False, _
      Tab:=False, Semicolon:=False, _
      Comma:=False, Space:=False, _
      Other:=True, OtherChar:="|"
    Do While I < UBound(xFilesToOpen)
        I = I + 1
        Set xTempWb = Workbooks.Open(xFilesToOpen(I))
        With xWb
            xTempWb.Sheets(1).Move after:=.Sheets(.Sheets.Count)
            .Worksheets(I).Columns("A:A").TextToColumns _
              Destination:=Range("A1"), DataType:=xlDelimited, _
              TextQualifier:=xlDoubleQuote, _
              ConsecutiveDelimiter:=False, _
              Tab:=False, Semicolon:=False, _
              Comma:=False, Space:=False, _
              Other:=True, OtherChar:=xDelimiter
        End With
    Loop
ExitHandler:
    Application.ScreenUpdating = xScreen
    Set xWb = Nothing
    Set xTempWb = Nothing
    Exit Sub
ErrHandler:
    MsgBox Err.Description, , "Kutools for Excel"
    Resume ExitHandler
End Sub

3. Ar ôl pasio'r cod uchod, pwyswch F5 allwedd i redeg y cod hwn, ac yn y ffenestr popped out, nodwch y ffolder sy'n cynnwys y ffeiliau testun, ewch i'r ffolder i ddewis y ffeiliau testun rydych chi am eu mewnforio i'r taflenni gwaith, gweler y screenshot:

mewnforio ffeiliau testun lluosog 1

4. Yna cliciwch agored botwm, mae'r holl ffeiliau testun a ddewiswyd wedi'u mewnforio i lyfr gwaith newydd a phob ffeil wedi'i lleoli mewn un daflen waith yn unigol.

5. O'r diwedd, gallwch arbed y llyfr gwaith newydd yn ôl yr angen.


swigen dde glas saeth Rhannwch lyfr gwaith i ffeiliau testun / pdf / csv / xlsx lluosog ar wahân gyda Kutools ar gyfer Excel

Weithiau, efallai y bydd angen i chi wneud rhai gweithrediadau cyferbyniol â'r dasg uchod, hynny yw, mae angen i chi rannu llyfr gwaith i wahanu ffeiliau testun. Kutools ar gyfer Excel'S Llyfr Gwaith Hollti gall cyfleustodau eich helpu chi i ddatrys y swydd hon yn gyflym ac yn hawdd.

Kutools ar gyfer Excel : gyda mwy na 300 o ychwanegiadau Excel defnyddiol, am ddim i geisio heb unrhyw gyfyngiad mewn 30 diwrnod

Ar ôl gosod Kutools ar gyfer Excel, gwnewch fel a ganlyn :( Am ddim Lawrlwythwch Kutools ar gyfer Excel Nawr! )

1. Gweithredwch y llyfr gwaith rydych chi am ei rannu i ffeiliau testun lluosog.

2. Cliciwch Menter > Llyfr Gwaith > Llyfr Gwaith Hollti, gweler y screenshot:

3. Yn y Llyfr Gwaith Hollti blwch deialog:

(1.) Gwiriwch y taflenni gwaith rydych chi am eu rhannu.

(2.) Gwiriwch Nodwch fformat arbed, yna dewiswch y fformat ffeil rydych chi am ei arbed, er enghraifft, gallwch chi ddewis txt, csv, pdf, xlsx or xls fformat ffeil yn ôl yr angen.

(3.) Yna cliciwch Hollti botwm, yn y blwch prydlon canlynol nodwch ffolder i allbwn y ffeiliau ar wahân.

rhagori ar flwch deialog llyfr gwaith rhaniad ychwanegion 2 rhagori ar leoliad dewis ychwanegiad

4. Yna cliciwch OK botwm, a bydd y taflenni gwaith a ddewiswyd gennych yn cael eu rhannu a'u cadw i'ch ffolder a ddymunir gyda'r fformat yn ôl yr angen.

rhagori ar ffeiliau ychwanegu ar wahân

Am ddim Lawrlwythwch Kutools ar gyfer Excel Nawr!

Offer Cynhyrchiant Swyddfa Gorau

🤖 Kutools AI Aide: Chwyldro dadansoddi data yn seiliedig ar: Cyflawniad Deallus   |  Cynhyrchu Cod  |  Creu Fformiwlâu Personol  |  Dadansoddi Data a Chynhyrchu Siartiau  |  Invoke Swyddogaethau Kutools...
Nodweddion Poblogaidd: Darganfod, Amlygu neu Adnabod Dyblygiadau   |  Dileu Rhesi Gwag   |  Cyfuno Colofnau neu Gelloedd heb Colli Data   |   Rownd heb Fformiwla ...
Super-edrych: VLookup Meini Prawf Lluosog    VLookup Gwerth Lluosog  |   VLookup Ar Draws Taflenni Lluosog   |   Edrych Niwlog ....
Rhestr gwympo Uwch: Creu Rhestr Gollwng yn Gyflym   |  Rhestr Gollwng Dibynnol   |  Rhestr Gollwng Aml-ddewis ....
Rheolwr Colofn: Ychwanegu Nifer Penodol o Golofnau  |  Symud Colofnau  |  Toglo Statws Gwelededd Colofnau Cudd  |  Cymharwch Ystodau a Cholofnau ...
Nodweddion dan Sylw: Ffocws ar y Grid   |  Golwg Dylunio   |   Bar Fformiwla Mawr    Rheolwr Llyfr Gwaith a Thaflen   |  Llyfrgell Adnoddau (Testun Auto)   |  Dewiswr Dyddiad   |  Cyfuno Taflenni Gwaith   |  Amgryptio/Dadgryptio Celloedd    Anfon E-byst trwy Restr   |  Hidlo Super   |   Hidlo Arbennig (hidlo mewn print trwm/italig/strikethrough...) ...
15 Set Offer Gorau12 Testun offer (Ychwanegu Testun, Dileu Cymeriadau,...)   |   50 + Siart Mathau (Siart Gantt,...)   |   40+ Ymarferol Fformiwlâu (Cyfrifwch oedran yn seiliedig ar ben-blwydd,...)   |   19 mewnosod offer (Mewnosod Cod QR, Mewnosod Llun o'r Llwybr,...)   |   12 Trosi offer (Rhifau i Eiriau, Trosi arian cyfred,...)   |   7 Uno a Hollti offer (Rhesi Cyfuno Uwch, Celloedd Hollt,...)   |   ... a mwy

Supercharge Eich Sgiliau Excel gyda Kutools ar gyfer Excel, a Phrofiad Effeithlonrwydd Fel Erioed Erioed. Kutools ar gyfer Excel Yn Cynnig Dros 300 o Nodweddion Uwch i Hybu Cynhyrchiant ac Arbed Amser.  Cliciwch Yma i Gael Y Nodwedd Sydd Ei Angen Y Mwyaf...

Disgrifiad


Mae Office Tab yn dod â rhyngwyneb Tabbed i Office, ac yn Gwneud Eich Gwaith yn Haws o lawer

  • Galluogi golygu a darllen tabbed yn Word, Excel, PowerPoint, Cyhoeddwr, Mynediad, Visio a Phrosiect.
  • Agor a chreu dogfennau lluosog mewn tabiau newydd o'r un ffenestr, yn hytrach nag mewn ffenestri newydd.
  • Yn cynyddu eich cynhyrchiant 50%, ac yn lleihau cannoedd o gliciau llygoden i chi bob dydd!
Comments (10)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I had tried with a txt file where there were multiple tables with numbers saved with commas but the program did not recognize the comma as a decimal point. How can I fix this error?
This comment was minimized by the moderator on the site
What would I need to change in the code to make it not open them in a new workbook?
This comment was minimized by the moderator on the site
This code helped me exactly to solve my issue, thanks for the code.
This comment was minimized by the moderator on the site
thank you , multiple text files to different worksheets code worked!
This comment was minimized by the moderator on the site
Thanks for this code this is working great.. i want to merge all the selected sheet into a single sheet is that possible..
This comment was minimized by the moderator on the site
How do I change this macros to display text file saved as UTF-8 or in other words using Platform = 65001, Thanks
This comment was minimized by the moderator on the site
Thanks for this very useful code. I have a question though. What I can change to convert the datatype from General to Text as currently it only imports data into General format.
This comment was minimized by the moderator on the site
Is it possible to open Sequencially multiple txt files in a single sheet ?
This comment was minimized by the moderator on the site
The code for "Import multiple text files to separate worksheets with VBA code" works for me, BUT cuts off the data of each cell at 255 characters. I think it is defaulting to GeneralFormat cell data, but I need it to be TextFormat. Unfortunately I cannot figure out how to adjust the code to fix this.
This comment was minimized by the moderator on the site
I used Following code But Space Didn't Delimit. Turned Tab:=True, Space:=True, but it didn't work. My Txt file format is- ALUMINI16MAYFUT 09-05-2016 10:00:00 106.0000 106.0000 105.2000 105.3500 104 Any Solution?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations