Macro to fetch csv file and edit the file
Hi Team,
I got a code from this forum to create a macro and fetch a csv file. Code is as below. Now after fetching the csv file, i am not just going to save in my desktop instead my macro should edit the csv file and add the table name in the first line of the csv file. Because i have to upload this csv file to my web application which will store the data in the table
Code:
Sub SaveasCSV()
Dim strPath As String
Dim strFileName As String
strPath = "C:\Users\324954\Desktop\" ' Use your Path
strFileName = "MyFile" ' Use your File Name
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=strPath & strFileName, _
FileFormat:=xlCSV, CreateBackup:=False
Application.DisplayAlerts = True
End Sub
Also in my excel file where user will enter the data and run the macro, not all the columns are fetched into a csv file only some selected columns will be fetched as csvfile1, remaining columns will be fetched as another csv file say csv file2.
In simple words running my macro user should get two csv files. Columns I can hardcode in my code like which columns will fit into csvfile 1 and which all to next file. User will not know that.
Kindly let me know how i can achieve that.
Please advise and provide me some help in coding the same.
Regards
Dhivya