Consulting

Results 1 to 2 of 2

Thread: VBA Code to create a folder based on cell date

  1. #1
    VBAX Regular
    Joined
    Feb 2018
    Posts
    15
    Location

    VBA Code to create a folder based on cell date

    Good Day

    Looking for some help on a VBA Code that will create a folder based on a Cell Date.

    I have the following Code

    HTML Code:
    MkDir Sheet1.Range("B4") & "\Incident Database\" & Sheet3.Range("O1") & " " & Sheet3.Range("M3") & " " & Sheet3.Range("A3") & " " & Sheet3.Range("J3") & "\"
    To clarify the references:
    Sheet1.Range("B4") = C:\VBA Application
    Sheet3.Range("O1") = INC-0001
    Sheet3.Range("M3") = 2018-01-01
    Sheet3.Range("A3") = Enivornment
    Sheet3.Range("J3") = Minor

    Basically resulting in a folder being created that looks like this:
    C:\VBA Application\Incident Database\INC-0001 2018-01-01 Environment Minor\

    The date in the cell appears as 2018-01-01 all viable characters to create a folder. however I keep getting a run time error "76". if i remove Sheet3.Range("M3") it works but i don't have the date. do i need to format the date somehow perhaps?

  2. #2
    VBAX Regular
    Joined
    Feb 2018
    Posts
    15
    Location
    Apologies for replying to my own thread.

    But I managed to fix my own problem.

    I renamed Sheet3.range("M3") to Format(Sheet3.Range("M3"), "yyyy-mm-dd") and it worked perfectly.

Posting Permissions

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