VBA Folders: Create or Move Folders to match Directory

arcaidius

New Member
Joined
Dec 4, 2018
Messages
42
Goal: Need Folders to match names in Column C of Spreadsheet
IF Folder Exists. Do nothing
IF Folder Does Not Exist. Create
IF Folder Name is not found in Column C, Move to different location

Mighty Excel Masters please help, maybe you can tweak the code i have? It worked to create all the folders but not sure how to tweak it.

VBA Code:
Sub UpdateFolders_Click()

Dim Rng As Range

Dim maxRows, maxCols, r, c As Integer

Set Rng = Range("C1:C99")

maxRows = Rng.Rows.Count

maxCols = Rng.Columns.Count

For c = 1 To maxCols

r = 1

Do While r <= maxRows

If Len(Dir("C:\Location\Location\Location" & "\" & Rng(r, c), vbDirectory)) = 0 Then

MkDir ("C:\Location\Location\Location " & "\" & Rng(r, c))

On Error Resume Next

End If

r = r + 1

Loop

Next c

End Sub
 
Last edited by a moderator:

Some videos you may like

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

arcaidius

New Member
Joined
Dec 4, 2018
Messages
42
Maybe I need to clarify what I'm Missing?

I need the code to check if a folder exists in the location but does not exist in column C, and move that folder to a different location.

Example: The list in column C is employees, if an employee quits than they are removed from the list and I need this Macro to move that employees folder to a different location in case they are re-hired, the documents will still be available. Maybe I can check that location first before creating a new folder?
 

arcaidius

New Member
Joined
Dec 4, 2018
Messages
42
Can anyone help with this? I need this to move any folder that does NOT match the name in Column C to a different destination.
 

Watch MrExcel Video

Forum statistics

Threads
1,128,099
Messages
5,628,679
Members
416,332
Latest member
blkbeltmjk

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top