Forum Discussion

JoAvg's avatar
JoAvg
Brass Contributor
May 15, 2022
Solved

MACRO - Create Folder/Subfolder based on Today and single cell values - Create *.xlsx in that folder

Hello everyone, newcomer here. I have a book with two main sheets: Overview with ref's to sheet Formulas which is a bunch of index/lookup/search functions. I am in need of two macros in Overview sh...
  • HansVogelaar's avatar
    May 15, 2022

    JoAvg 

    Sub Macro2()
        Dim wbkT As Workbook
        Dim wshS As Worksheet
        Dim wshT As Worksheet
        Dim sPath As String
        Dim sDate As String
        Dim sCity As String
        Dim sAddress As String
        Dim sFile As String
        Set wshS = ThisWorkbook.Worksheets("Formulas")
        Set wbkT = Workbooks.Add(xlWBATWorksheet)
        Set wshT = wbkT.Worksheets(1)
        wshT.Range("A53:I54").Value = wshS.Range("A53:I54").Value
        sPath = CreateObject("WScript.Shell").SpecialFolders("Desktop")
        sDate = Format(Date, "dd mm yyyy")
        sPath = sPath & "\Delivery\" & sDate
        sCity = wshS.Range("A5").Value
        sPath = sPath & "\" & sCity
        sAddress = wshS.Range("A6").Value
        sPath = sPath & "\" & sAddress
        sFile = "Station.xlsx"
        sPath = sPath & "\" & sFile
        wbkT.SaveAs Filename:=sPath, FileFormat:=xlOpenXMLWorkbook
        wbkT.Close
    End Sub

Resources