메인 컨텐츠로 가기

여러 텍스트 파일을 여러 시트로 가져 오는 방법은 무엇입니까?

컴퓨터 폴더에 여러 텍스트 파일이 있다고 가정하면 이제 이러한 텍스트 파일을 Excel 통합 문서로 가져오고 각 텍스트 파일을 별도의 워크 시트에 배치하려고합니다. 각 텍스트 파일을 하나씩 복사하여 워크 시트에 붙여 넣으면 많은 시간이 낭비됩니다. 여기서는이 문제를 해결하기위한 몇 가지 트릭에 대해 이야기 할 수 있습니다.

VBA 코드를 사용하여 여러 텍스트 파일을 별도의 워크 시트로 가져옵니다.

Excel 용 Kutools를 사용하여 통합 문서를 여러 개의 개별 텍스트 / pdf / csv / xlsx 파일로 분할


화살표 블루 오른쪽 거품 VBA 코드를 사용하여 여러 텍스트 파일을 별도의 워크 시트로 가져옵니다.

다음 VBA 코드는 각 텍스트 파일을 새 통합 문서 내의 별도 시트로 한 번에 가져 오는 데 도움이 될 수 있습니다. 다음과 같이하십시오.

1. 누르고 ALT + F11 Excel에서 키를 열려면 응용 프로그램 용 Microsoft Visual Basic 창.

2. 딸깍 하는 소리 끼워 넣다 > 모듈을 클릭하고 다음 코드를 모듈 창문.

VBA 코드 : 여러 텍스트 파일을 별도의 워크 시트로 가져옵니다.

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. 위 코드를 붙여 넣은 후 F5 이 코드를 실행하려면 키를 누르고 팝업 창에서 텍스트 파일이 포함 된 폴더를 지정하고 폴더로 이동하여 워크 시트로 가져올 텍스트 파일을 선택하십시오. 스크린 샷을 참조하십시오.

문서 가져 오기 여러 텍스트 파일 1

4. 그런 다음 엽니다 버튼을 클릭하면 선택한 모든 텍스트 파일이 새 통합 문서로 가져오고 각 파일은 하나의 워크 시트에 개별적으로 있습니다.

5. 마침내 필요에 따라 새 통합 문서를 저장할 수 있습니다.


화살표 블루 오른쪽 거품 Excel 용 Kutools를 사용하여 통합 문서를 여러 개의 개별 텍스트 / pdf / csv / xlsx 파일로 분할

경우에 따라 위 작업과 반대되는 작업을 수행해야 할 수도 있습니다. 즉, 통합 문서를 별도의 텍스트 파일로 분할해야합니다. Excel 용 Kutools통합 문서 분할 유틸리티를 사용하면이 작업을 빠르고 쉽게 해결할 수 있습니다.

Excel 용 Kutools : 300 개 이상의 편리한 Excel 추가 기능으로 30 일 동안 제한없이 무료로 사용해 볼 수 있습니다.

설치 후 Excel 용 Kutools, 다음과 같이하십시오 :( 지금 Excel 용 Kutools를 무료로 다운로드하십시오! )

1. 여러 텍스트 파일로 분할 할 통합 문서를 활성화합니다.

2. 딸깍 하는 소리 Enterprise > 통합 문서 > 통합 문서 분할, 스크린 샷 참조 :

3. 에서 통합 문서 분할 대화 상자 :

(1.) 분할하려는 워크 시트를 확인합니다.

(2.) 확인 저장 형식 지정을 클릭 한 다음 저장할 파일 형식을 선택합니다. 예를 들어 TXT, csv 파일, PDF, XLSX or XLS 필요에 따라 파일 형식.

(3.) 그런 다음 스플릿 버튼을 클릭하면 다음 프롬프트 상자에서 별도의 파일을 출력 할 폴더를 지정합니다.

Excel 추가 기능 분할 통합 문서 대화 상자 2 엑셀 추가 기능 선택 위치

4. 그런 다음 OK 버튼을 클릭하면 선택한 워크 시트가 분할되어 필요한 형식으로 원하는 폴더에 저장됩니다.

엑셀 추가 기능 별도 파일

지금 Excel 용 Kutools를 무료로 다운로드하십시오!

최고의 사무 생산성 도구

🤖 Kutools AI 보좌관: 다음을 기반으로 데이터 분석을 혁신합니다. 지능형 실행   |  코드 생성  |  사용자 정의 수식 만들기  |  데이터 분석 및 차트 생성  |  Kutools 기능 호출...
인기 기능: 중복 항목 찾기, 강조 표시 또는 식별   |  빈 행 삭제   |  데이터 손실 없이 열이나 셀 결합   |   수식없이 반올림 ...
슈퍼 조회: 다중 기준 VLookup    다중 값 VLookup  |   여러 시트에 걸친 VLookup   |   퍼지 조회 ....
고급 드롭다운 목록: 드롭다운 목록을 빠르게 생성   |  종속 드롭다운 목록   |  다중 선택 드롭 다운 목록 ....
열 관리자: 특정 개수의 열 추가  |  열 이동  |  Toggle 숨겨진 열의 가시성 상태  |  범위 및 열 비교 ...
특색 지어진 특징: 그리드 포커스   |  디자인보기   |   큰 수식 바    통합 문서 및 시트 관리자   |  리소스 라이브러리 (자동 텍스트)   |  날짜 선택기   |  워크 시트 결합   |  셀 암호화/해독    목록으로 이메일 보내기   |  슈퍼 필터   |   특수 필터 (굵게/기울임꼴/취소선 필터링...) ...
상위 15개 도구 세트12 본문 도구 (텍스트 추가, 문자 제거,...)   |   50+ 거래차트 유형 (Gantt 차트,...)   |   40+ 실용 방식 (생일을 기준으로 나이 계산,...)   |   19 삽입 도구 (QR 코드 삽입, 경로에서 그림 삽입,...)   |   12 매출 상승 도구 (숫자를 단어로, 환율,...)   |   7 병합 및 분할 도구 (고급 결합 행, 셀 분할,...)   |   ... 그리고 더

Excel용 Kutools로 Excel 기술을 강화하고 이전과는 전혀 다른 효율성을 경험해 보세요. Excel용 Kutools는 생산성을 높이고 시간을 절약하기 위해 300개 이상의 고급 기능을 제공합니다.  가장 필요한 기능을 얻으려면 여기를 클릭하십시오...

상품 설명


Office Tab은 Office에 탭 인터페이스를 제공하여 작업을 훨씬 쉽게 만듭니다.

  • Word, Excel, PowerPoint에서 탭 편집 및 읽기 사용, Publisher, Access, Visio 및 Project.
  • 새 창이 아닌 동일한 창의 새 탭에서 여러 문서를 열고 만듭니다.
  • 생산성을 50% 높이고 매일 수백 번의 마우스 클릭을 줄입니다!
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