use of MKDIR Function in Excel Vba

MKDIR

 

In excel vba we use MKDIR vba function to create folder.

MKDIR Function का उपयोग हम excel vba में folder बनाने के लिए करते है.


I have to make a folder in D Drive which name will be computer. For this we have type code

हमें D drive में एक फोल्डर बनाना है जिसका नाम COMPUTER होगा. इसके लिए हमें यह कोड लिखना होगा.

Sub MakeFolder()
MkDir “D:\COMPUTER”
End Sub

This Code will make folder in D Drive.

यह code D Drive में फोल्डर बना देगा.


I have a folder in D Drier Which name if Computer and I have some value in excel A1 TO A5, I want that make a new folder in D:\COMPUTER with each cell value which is mentioned in A1 TO A5 range. For this we have to use below code.

D Drive में computer नाम का folder है और excel sheet में A1 से A5 तक कुछ value है. हमें प्रत्येक cell value से folder बनाना है D:\COMPUTER में, इसके लिए हमें यह कोड लिखना होगा.

 

 

 

 

 

 

 

 

Sub makefolder1()
For Each CELL In Range(“a1:a5”)
MkDir “D:\COMPUTER\” & CELL.Value
Next CELL

End Sub


I want to check, COMPUTER named folder locate in D Drive or not, if folder exist then “Folder Exist” Message Will be appeared in message box, if not exist then “Folder Not Exist” in message box.

हमें यह check करना है की, COMPUTER नाम का Folder D Drive में है की नहीं, अगर Folder है तो message में “Folder Exist” show करेगा. अगर Folder नहीं है तो message में “Folder Not Exist” show करेगा.

Sub checkfolder()
If Len(Dir(“D:\COMPUTER\”, vbDirectory)) > 0 Then
MsgBox “Folder Exist”
Else
MsgBox “Folder Not Exist”
End If
End Sub

 

Click here to download Excel File.

Click Here to Watch Video

 

2 comments

Leave a Reply to vinod panwar Cancel reply

Your email address will not be published. Required fields are marked *