VBA Folders: Create or Move Folders to match Directory

arcaidius

Board Regular
Joined
Dec 4, 2018
Messages
97
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:

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
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?
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

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
Back
Top