메인 컨텐츠로 가기

Excel의 데이터 목록에서 여러 폴더 및 하위 폴더 만들기

워크시트 범위 내에 직원 이름 목록이 있고 각 직원의 정보를 저장할 개별 폴더를 만드는 것을 목표로 한다고 가정합니다. 각 폴더를 수동으로 생성하는 데는 시간이 많이 걸릴 수 있습니다. 그러나 이 프로세스를 신속하게 처리할 수 있는 효율적인 방법이 있습니다. 이 가이드에서는 지정된 셀 값을 기반으로 폴더를 빠르게 생성하는 몇 가지 접근 방식을 공유하겠습니다.

셀 값을 기반으로 폴더 만들기

VBA 코드를 사용하여 셀 값을 기반으로 폴더 및 하위 폴더 만들기


셀 값을 기반으로 폴더 만들기

이 섹션에서는 다양한 방법을 자세히 살펴보고 셀 값 목록을 기반으로 폴더를 빠르고 쉽게 만드는 포괄적인 단계별 지침을 제공합니다.

MD 명령과 메모장을 사용하여 목록에서 폴더 만들기

MD 명령과 메모장을 사용하여 Excel의 목록을 폴더로 바꾸는 것은 쉬운 배치 스크립팅과 Excel의 정리 능력을 결합한 현명한 방법입니다. 이 방법은 모든 작업을 직접 수행할 필요 없이 많은 폴더를 빠르게 만드는 데 적합합니다. 이 작업을 수행하기 위한 단계별 가이드는 다음과 같습니다.

1단계: MD 명령을 사용하여 수식 만들기

첫 번째 셀 값(예: B1) 옆의 빈 셀에 다음 수식을 복사하거나 입력한 다음 채우기 핸들을 아래로 끌어 모든 목록 항목에 수식을 적용합니다.

="MD "&A1

2단계: 수식을 복사하여 메모장 파일에 붙여넣기

  1. PR 기사 Ctrl + C MD 명령 수식을 사용하여 셀을 복사합니다.
  2. 엽니다 메모장 키를 누릅니다 Ctrl + V 명령을 새 파일에 붙여넣습니다.

3단계: 메모장 파일을 .bat 파일로 저장

다른 이름으로 저장 인사말 입양 부모로서의 귀하의 적합성을 결정하기 위해 미국 이민국에 메모장의 탭에서 다른 이름으로 저장 대화 상자에서 여러 폴더를 생성하려는 디렉터리를 선택한 다음 박쥐 확대. 마지막으로 클릭하세요. 찜하기 단추. 스크린 샷보기 :

4단계: .bat 파일을 두 번 클릭하여 여러 폴더를 생성합니다.

  1. 메모장 파일을 닫고 이전에 .bat 파일을 저장한 폴더로 이동합니다.
  2. 이제 마술을 목격하십시오. 파일을 두 번 클릭하면 여러 폴더가 동시에 생성되는 것을 볼 수 있습니다. 아래 데모를 참조하세요.
 

강력한 도구를 사용하여 목록에서 폴더 만들기 – Excel용 Kutools

강력한 사람들과 함께 Excel 용 Kutools셀 내용에서 폴더 만들기 기능을 사용하면 이제 Excel 목록에서 폴더를 쉽고 빠르게 만들 수 있습니다. 하지만 이는 기본 폴더에만 국한되지 않습니다. Kutools를 사용하면 한 번에 여러 수준의 하위 폴더로 복잡한 구조를 만들 수 있습니다. 몇 가지 간단한 단계만으로 Excel의 데이터를 정리된 폴더 시스템으로 변환하여 생산성을 크게 높일 수 있습니다.

주의 사항: 이것을 사용하고 싶다면 셀 내용에서 폴더 만들기 기능 부탁드립니다 Excel 용 Kutools 다운로드 및 설치 먼저.

설치 후 Excel 용 Kutools클릭하세요 쿠툴즈 플러스 > 수입 수출 > 셀 내용에서 폴더 만들기 를 열려면 셀 내용에서 폴더 만들기 대화 상자 :

  1. 폴더를 만들려는 셀 값을 선택하세요.
  2. 그런 다음 폴더를 저장하려는 대상 폴더를 지정하는 버튼;
  3. 마지막으로,을 클릭하십시오 OK 버튼을 클릭합니다.

결과 :

Kutools는 시트의 목록을 처리하고 지정된 대상의 각 항목에 대한 폴더를 생성합니다. 결과를 보려면 대상 폴더로 이동하십시오. 스크린샷 보기:

팁 :
  1. 이 유용한 기능은 다음에도 도움이 될 수 있습니다. 하위 폴더와 함께 폴더 생성 당신이 필요로하는대로. 이렇게 하려면 백슬래시 기호(\)를 사용하여 각 수준을 구분하여 원하는 폴더 및 하위 폴더 이름을 셀에 입력해야 합니다. 각 셀의 내용은 원하는 폴더 및 하위 폴더 구조를 설정하기 위한 가이드 역할을 합니다.

    그런 다음 셀 내용에서 폴더 만들기 기능을 사용하면 하위 폴더와 함께 모든 폴더가 성공적으로 생성됩니다. 스크린샷 보기:
  2. 이 기능을 적용하려면 Excel 용 Kutools 다운로드 및 설치 먼저.
 

VBA 코드를 사용하여 목록에서 폴더 만들기

Excel에서 VBA 코드를 사용하면 목록에서 폴더를 만드는 지루한 작업을 빠르고 자동화된 프로세스로 변환할 수 있습니다. 이 섹션에서는 VBA 코드를 적용하여 폴더를 생성하는 방법을 보여줍니다.

1단계: VBA 모듈 편집기를 열고 코드를 복사합니다.

  1. 누르고있어. ALT + F11 Excel에서 키를 클릭하고 응용 프로그램 용 Microsoft Visual Basic 창.
  2. 끼워 넣다 > 모듈을 클릭하고 다음 코드를 모듈 창문.
    VBA 코드: 셀 값 목록을 기반으로 폴더 만들기
    Sub CreateFoldersFromSelection()
    'Updateby Extendoffice
        Dim FolderPath As String
        Dim Cell As Range
        Dim SelectedRange As Range
        Dim FolderName As String
        On Error Resume Next
        Set SelectedRange = Application.InputBox("Select the range with folder names", "Kutools for Excel", Type:=8)
        If SelectedRange Is Nothing Then Exit Sub
        On Error GoTo 0
        
        With Application.FileDialog(msoFileDialogFolderPicker)
            .Title = "Select the destination Folder"
            .AllowMultiSelect = False
            If .Show <> -1 Then Exit Sub
            FolderPath = .SelectedItems(1) & "\"
        End With
        
        For Each Cell In SelectedRange
            FolderName = FolderPath & Cell.Value
            If Cell.Value <> "" And Not FolderExists(FolderName) Then
                MkDir FolderName
            End If
        Next Cell
    End Sub
    
    Function FolderExists(ByVal Path As String) As Boolean
        On Error Resume Next
        FolderExists = (GetAttr(Path) And vbDirectory) = vbDirectory
        On Error GoTo 0
    End Function
    

2단계: 코드 실행

  1. 이 코드를 붙여 넣은 후 F5 이 코드를 실행하는 키입니다. 프롬프트 상자에서 폴더를 만들려는 셀 값을 선택합니다. 그런 다음 클릭하세요. OK.
  2. 그러면 다음에서 대상 폴더를 선택하세요 창에서 생성된 폴더를 출력할 대상 경로를 지정합니다. 그런 다음 클릭하세요. OK 버튼, 스크린 샷 참조 :

결과 :

VBA 코드를 실행한 후 대상 디렉터리로 이동하여 결과를 확인하세요. 거기에서 각각 Excel 목록의 항목에 해당하는 새로 생성된 폴더를 찾을 수 있습니다. 스크린샷을 참조하세요:

팁 :
  1. 셀에 중복된 항목이 있는 경우 코드를 실행하면 해당 중복 항목에 대해 하나의 폴더만 생성됩니다.
  2. 이 코드를 자주 사용하는 경우 통합 문서를 다음 위치에 저장하는 것이 좋습니다. Excel 매크로 사용 통합 문서 체재. 이 작업을 수행하면 통합 문서 내의 코드가 보존되므로 나중에 코드를 다시 입력하거나 다시 가져올 필요 없이 직접 실행할 수 있습니다.

VBA 코드를 사용하여 셀 값을 기반으로 폴더 및 하위 폴더 만들기

때로는 Excel 셀 내의 데이터를 기반으로 폴더뿐만 아니라 해당 하위 폴더도 생성해야 하는 상황에 처할 수 있습니다. 이 작업을 수행하기 위해 여기서는 VBA 코드를 소개하겠습니다.

1단계: 데이터 준비

먼저 표시된 다음 스크린샷과 같이 데이터를 입력해야 하며, 첫 번째 열에 기본 폴더 이름을 배치하고 두 번째 열에 하위 폴더 이름을 배치해야 합니다.

2단계: VBA 모듈 편집기를 열고 코드를 복사합니다.

  1. 누르고있어. ALT + F11 Excel에서 키를 클릭하고 응용 프로그램 용 Microsoft Visual Basic 창.
  2. 끼워 넣다 > 모듈을 클릭하고 다음 코드를 모듈 창문.
    VBA 코드: 셀 값을 기반으로 폴더 및 하위 폴더 만들기
    Sub CreateFoldersAndSubfoldersWithUserInput()
    'Updateby Extendoffice
        Dim Rng As Range
        Dim Cell As Range
        Dim basePath As String
        Dim fldrPicker As FileDialog
        Dim FolderPath As String, subfolderPath As String
        On Error Resume Next
        Set Rng = Application.InputBox("Select the range of cells (two columns: one is folder column, another s subfolder column):", "Kutools for Excel", Type:=8)
        If Rng Is Nothing Then Exit Sub
        On Error GoTo 0
        Set fldrPicker = Application.FileDialog(msoFileDialogFolderPicker)
        With fldrPicker
            .Title = "Select the Base Folder Path"
            .AllowMultiSelect = False
            If .Show <> -1 Then Exit Sub
            basePath = .SelectedItems(1)
        End With
        If Right(basePath, 1) <> "\" Then basePath = basePath & "\"
        For Each Cell In Rng.Columns(1).Cells
            If Not Cell.Value = "" Then
                FolderPath = basePath & Cell.Value
                If Not FolderExists(FolderPath) Then MkDir FolderPath
                If Not Cell.Offset(0, 1).Value = "" Then
                    subfolderPath = FolderPath & "\" & Cell.Offset(0, 1).Value
                    If Not FolderExists(subfolderPath) Then MkDir subfolderPath
                End If
            End If
        Next Cell
    End Sub
    
    Function FolderExists(FolderPath As String) As Boolean
        On Error Resume Next
        FolderExists = (GetAttr(FolderPath) And vbDirectory) = vbDirectory
        On Error GoTo 0
    End Function
    

3단계: 코드 실행

  1. 이 코드를 붙여 넣은 후 F5 이 코드를 실행하는 키입니다. 프롬프트 상자에서 폴더를 만들려는 셀 값을 선택합니다. 그런 다음 클릭하세요. OK.
  2. 다음 팝업 창에서 생성된 폴더를 출력할 대상 경로를 지정합니다. 그런 다음 클릭하세요. OK 버튼, 스크린 샷 참조 :

결과 :

VBA 코드를 실행한 후 대상 디렉터리로 이동하여 결과를 확인합니다. 셀 값에 따라 폴더와 해당 하위 폴더가 다음 스크린샷과 같이 성공적으로 생성되었음을 확인할 수 있습니다.

팁 :
  1. 이 코드는 기본 폴더와 해당 첫 번째 수준 하위 폴더만 생성하는 데에만 사용할 수 있습니다.
  2. 이 코드를 자주 사용하는 경우 통합 문서를 다음 위치에 저장하는 것이 좋습니다. Excel 매크로 사용 통합 문서 체재. 이 작업을 수행하면 통합 문서 내의 코드가 보존되므로 나중에 코드를 다시 입력하거나 다시 가져올 필요 없이 직접 실행할 수 있습니다.

관련 기사:

  • Excel의 모든 폴더 및 하위 폴더 나열
  • 지정된 디렉토리의 모든 폴더와 하위 폴더를 워크 시트에 나열하는이 문제를 겪은 적이 있습니까? Excel에서는 특정 디렉터리에있는 모든 폴더의 이름을 한 번에 가져 오는 빠르고 편리한 방법이 없습니다. 작업을 처리하기 위해이 기사가 도움이 될 수 있습니다.
  • 목록을 기반으로 한 폴더에서 다른 폴더로 파일 복사 또는 이동
  • 워크 시트의 열에 파일 이름 목록이 있고 해당 파일이 컴퓨터의 폴더에있는 경우. 그러나 이제 다음 스크린 샷과 같이 워크 시트에 이름이 나열된 파일을 원래 폴더에서 다른 폴더로 이동하거나 복사해야합니다. 이 작업을 Excel에서 최대한 빨리 완료하려면 어떻게해야합니까?
  • 폴더의 여러 파일 이름 바꾸기
  • 폴더에있는 여러 파일의 이름을 바꿔야하는이 문제로 인해 우리 대부분은 고통을 겪을 수 있습니다. 파일 이름을 하나씩 바꾸려면 해당 폴더에 수백 또는 수천 개의 파일이 있으면 우리를 미치게 만듭니다. 이 작업을 처리 할 수있는 좋은 기능이 있습니까?
Comments (63)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
níže CZ verze

EN:

A better way to do this in a few seconds is to use cmd (.bat file)

If you have a list of names in excel, add the word MKdir in front of the name (folder name) and if it contains a space put the name in quotes. Then just copy it to notepad, save as and add the .bat extension. Once you have this, substitute the .bat file in the folder where it wants to be created and you're done.

If you want the cmd not to close write at the end of the puase like below

Here is the 3 word code *5* :

start
________
MKdir "Pixie Pin"

pause
________
end


this creates a folder named Pixie Pin in the folder where the command was run

CZ:

Lepší způsob jak to udělat během par sec. je použít cmd (.bat soubor)

Pokud máte seznam jmen v excelu, doplňte pomocí vzorečku slovo MKdir před jmeno (název složky) a pokud obsahuje mezeru dejte název do uvozovek. Poté stačí jen zkopírovat do oznámkového bloku (NotePad), dát uložit jako a dopsat příponu .bat . Jakmile toto máte, supsťte .bat soubor ve složce kde chce aby se vytvořili a máte to.

Pokud chcete aby se cmd nezavřelo napište na konec puase jako je níže

Zde je ten 3 slovný kód *5* :

start
________
MKdir "Pixie Pin"

pause
________
konec


toto vytvoří složku s názvem Pixie Pin ve složce kde byl příkaz spuštěn
This comment was minimized by the moderator on the site
This worked really well, even for someone with zero experience with VBA :-)
Would it be possible to adapt the macro or extend the macro to also create hyperlinks to the folders in the selected cells?
So for instance, Cell A3 is selected and you run the macro and the folder is created. Would it be possible to make cell A3 a hyperlink to the folder by expanding on the macro instead of doing that manually?
This comment was minimized by the moderator on the site
Hello, Marloes
To create hyperlinks for the cell values, the following vba code may help you:

First, please select the cell values, and then run this code, and select a folder for outputting the folders.

Sub MakeFoldersAndAddHyperlinksWithFolderSelection()
    Dim Rng As Range
    Dim maxRows, maxCols, r, c As Integer
    Dim folderPath As String
    Dim baseFolderPath As String
    Dim fd As FileDialog
    Set fd = Application.FileDialog(msoFileDialogFolderPicker)
    
    With fd
        If .Show = -1 Then
            baseFolderPath = .SelectedItems(1) & "\"
        Else
            MsgBox "No folder selected. Operation Cancelled."
            Exit Sub
        End If
    End With
    
    Set Rng = Selection
    maxRows = Rng.Rows.Count
    maxCols = Rng.Columns.Count
    
    For c = 1 To maxCols
        For r = 1 To maxRows
            folderPath = baseFolderPath & Rng.Cells(r, c).Value
            If Len(Dir(folderPath, vbDirectory)) = 0 Then
                MkDir folderPath
                On Error Resume Next
                ActiveSheet.Hyperlinks.Add Anchor:=Rng.Cells(r, c), Address:=folderPath, TextToDisplay:=Rng.Cells(r, c).Value
                On Error GoTo 0
            End If
        Next r
    Next c
End Sub


Please have a try, thank you!
This comment was minimized by the moderator on the site
please, i need that same macro but instead of saving them as folders, i need it to save as Excels.
This comment was minimized by the moderator on the site
is it possible to introduce a condition where if that condition is met the module can create 2 folders (each using a different path)?
if the first list of folders is in the A column then the condition occurs in the U column. The conditional criteria is whether the cell is empty or not.
if the condition is not met the module only makes one folder based on the selection.
This comment was minimized by the moderator on the site
Hi, a_c, sorry I have not found a method can solve this job yet.
This comment was minimized by the moderator on the site
Thank you very much
This comment was minimized by the moderator on the site
Thanks a lot! Your VBA code is really super
This comment was minimized by the moderator on the site
Is it possible to import data from a word to excel on colors algorythme? So, I spell the cities with red and countries with blue in a word, and the to import only these to excel. I don’t know if I made myself clear. Thanks
This comment was minimized by the moderator on the site
Thank you, this has saved me literally days of work.
This comment was minimized by the moderator on the site
Hello,


For the following code it shows error in

MkDir (ActiveWorkbook.Path & "\" & Rng(r, c))



It says Runtime error 76 path not found



Can someone please help me with this?

There are no unsupported characters in the file path.
Not sure what could be the problem

Thanks for the help!
This comment was minimized by the moderator on the site
thank you , time saved
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations