• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA code to create folder and inside create workbook

Vanadu

New Member
I need help with VBA code to make a folder - in the same folder where is the file I run macro. That folder must have the name from cell A4. In this folder I need to create excel file named from cell A6.


Example:IF in cell A4 is TTX and in cell A6 is 111. I need to create folder named TTX an inside to create file 111.xls or 111.xlsx.In this file 111.xls must be copyed - with formathing - all data between column F and column ATfrom the file I run macro.


Sorry for my bad English.
 

kchiba

Active Member
Hi Vanadu,


If the folder is with the same name as the file with the macro, then it already exists, so you do not need to create it, is that correct?
 

Vanadu

New Member
Hi, kchiba,

The name file with macro is TEST. So I need a VBA cod to make folder - with the name find in cell A2 (in this example is TTX). The excel file created in this folder will be teh name from cell B2 (in this example is 111.xls).

Hope you understand.
 

kchiba

Active Member
Hi Vanadu,


Try this code


Sub folder_file()

vFolder = ThisWorkbook.Sheets("Sheet1").Range("A2") 'Note folder name must include full path

vFile = ThisWorkbook.Sheets("Sheet1").Range("b2") 'include .xls in the name

On Error Resume Next

MkDir vFolder

On Error GoTo 0

ThisWorkbook.SaveAs Filename:=vFolder & "" & vFile, FileFormat:=xlExcel8


End Sub
 
Top