Create Folder based on cell value

Rahulwork

Active Member
Joined
Jun 9, 2013
Messages
284
Hello Everyone

I made below code to create multiple folder based on cell value but i want that path should also picked from the cell.

I have folder path in F4. so instead of folder path i want to add F4 in code. please help

VBA Code:
Sub AFolderVBA2() 'Excel VBA to make a folder.
Dim i As Integer

For i = 2 To 4

MkDir "Desktop:\ABC" & Range("AE" & i)

Next i

End Sub
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Hi
Do you mean like this?

VBA Code:
Sub AFolderVBA2() 'Excel VBA to make a folder.
Dim i As Integer
dim Path as string

Path=range("f4").value


For i = 2 To 4

MkDir Path & Range("AE" & i)

Next i

End Sub
 
Upvote 0
Where the "desktop:\ABC" is shown in cell F4 and pulled from there instead of embedded into the code?
 
Upvote 0
Can i ask one more question if you dont mind?

i have below code to move file from one folder to another. i have below code

Sub MoveFiles()
Dim FSO As Object
Dim SourceFileName As String, DestinFileName As String

Set FSO = CreateObject("Scripting.Filesystemobject")
SourceFileName = Range("AP2").Value
DestinFileName = Range("AR2").Value

FSO.MoveFile Source:=SourceFileName, Destination:=DestinFileName

End Sub

Query - I have some file in AP column start from 2nd row and same in AR i have their new path .

can we edit this code as per requirement so this would move all files mentioned in AP column
 
Upvote 0
VBA Code:
Sub MoveFiles()
    Dim FSO As Object
    Dim SourceFileName As String, DestinFileName As String
Dim I as long, LRow as long

lrow=cells(rows.count,42).end(xlup).row

for I = 2 to lrow

    Set FSO = CreateObject("Scripting.Filesystemobject")
    SourceFileName = Range("AP"& i).Value
    DestinFileName = Range("AR" & i).Value

    FSO.MoveFile Source:=SourceFileName, Destination:=DestinFileName

next i

 End Sub
 
Upvote 0

Forum statistics

Threads
1,223,238
Messages
6,170,939
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