PDA

View Full Version : Help to create a file from the inputs in the input sheet



aravind3107
07-25-2017, 10:33 PM
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"

offthelip
07-26-2017, 05:59 AM
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

aravind3107
07-26-2017, 07:14 PM
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.19892

offthelip
07-27-2017, 12:35 AM
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