Consulting

Results 1 to 4 of 4

Thread: Help to create a file from the inputs in the input sheet

  1. #1

    Post Help to create a file from the inputs in the input sheet

    Hi All,

    Please find below the requirement.

    I want create a CSV file from the inputs I have provided in the excel file. The requirement is .

    Have created a excel workbook where I have provided the names .

    Require user to select one name from the list and

    Input1: Name - Dropdown (User should select one)
    a. Aravind
    b. Ravi
    c. Ganesh
    d. Babu
    e. Kishore
    f. Satish
    g. Pradeep

    Input2: Report date – Openend Box (User should enter response in YYYYMMDD format)
    Input3: Date Time - Openend Box (User should enter response in YYYYMMDDHHMM format)


    Please help me to create a CSV file with the file name as "Aravind_20170725_201707261102"
    Attached Files Attached Files

  2. #2
    VBAX Expert
    Joined
    May 2016
    Posts
    604
    Location
    try this it save it in the same folder as the workbook

    Sub test()
    pathn = ActiveWorkbook.Path
    dattim = (Cells(2, 3))
    yr = Year(dattim)
    mo = Month(dattim)
    dy = Day(dattim)
    hr = Hour(dattim)
    Min = Minute(dattim)
    dattxt = yr & mo & dy & hr & Min
    flename = Cells(2, 1) & "_" & Cells(2, 2) & "_" & dattxt
    Workbooks.Add
    ActiveWorkbook.SaveAs Filename:=pathn & "\" & flename & ".csv", FileFormat:=xlCSV
    End Sub

  3. #3
    Hi Offthhelip,

    Thanks a lot for your help.

    Could you please let me know will it run with multiple lines in the template.

    I require multiple lines to be saved in the folder.Screenshot Temp.jpg

  4. #4
    VBAX Expert
    Joined
    May 2016
    Posts
    604
    Location
    try this: Note I have not tested this.

    Sub test()
    with activesheet
        lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
    end with 
       pathn = ActiveWorkbook.Path
        For i = 2 To lastrow
        dattim = (Cells(i, 3))
        yr = Year(dattim)
        mo = Month(dattim)
        dy = Day(dattim)
        hr = Hour(dattim)
        Min = Minute(dattim)
        dattxt = yr & mo & dy & hr & Min
        flename = Cells(i, 1) & "_" & Cells(i, 2) & "_" & dattxt
        Workbooks.Add
        ActiveWorkbook.SaveAs Filename:=pathn & "\" & flename & ".csv", FileFormat:=xlCSV
       next i
    End Sub

Posting Permissions

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