Consulting

Results 1 to 2 of 2

Thread: Creating a folder with cell contents

  1. #1
    VBAX Newbie
    Joined
    Apr 2011
    Posts
    1
    Location

    Creating a folder with cell contents

    I would like to
    1-create folder its name is the cell B8 + E4 value + today date
    2- if the folder exists overwrites
    3-copy all files to that folder from another folder its name is datafiles
    4-if there is no files in datafiles return (no files copied)

  2. #2
    VBAX Expert shrivallabha's Avatar
    Joined
    Jan 2010
    Location
    Mumbai
    Posts
    750
    Location
    Welcome to VBAX.

    Have a look at this thread which probably does a task similar to what you are setting out to do in Step 3.
    http://www.vbaexpress.com/forum/showthread.php?t=36352

    If you know a bit of VBA then the first part can be achieved by using FileSystemObject like:
    [vba]Sub CreateFolder()
    Dim objFSO As Object
    Dim sPath As String
    On Error GoTo ErrorHandler
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    sPath = Range("B8").Value & "\" & Range("E4").Value & "\" & Date$
    objFSO.CreateFolder (sPath)
    ErrorHandler:
    If Err.Number <> 0 Then
    Select Case Err.Number
    Case 58
    MsgBox "The Specified Folder Already Exists!"
    Case Else
    MsgBox Err.Description
    End Select
    End If
    End Sub
    [/vba]
    Regards,
    --------------------------------------------------------------------------------------------------------
    Shrivallabha
    --------------------------------------------------------------------------------------------------------
    Using Excel 2016 in Home / 2010 in Office
    --------------------------------------------------------------------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •