Hello everyone from Maurizio
My Problem is this:
I am trying to create a Csv file by taking only data from an excel sheet
in practice I want to take all the data that I insert starting from the Cell ("A2: D17") leaving out the various Headings of the various columns.
Now my problem is this: The File Comes Yes ...! created inside the "Attachments" folder But when I go to open the newly created file
I notice that there is nothing inside
Because !
Therefore I ask how to solve this problem Thanks
Greetings from A.Maurizio
Try this one:
Sub Crea_File_Csv()
Dim NewWb As Workbook: Set NewWb = Workbooks.Add
ThisWorkbook.Worksheets("Sheet1").Range("A2:D17").Copy Destination:=NewWb.Worksheets(1).Cells(1)
NewWb.SaveAs Filename:=ThisWorkbook.Path & "AllegatiEsporta.csv", FileFormat:=xlCSV, CreateBackup:=False
NewWb.Close True
End Sub
Hello Catalin Bombea As always I have to congratulate you because you are fantastic .
Although I have tried several times to change everything I have never been able to get anything.
Instead with your method it works .
Therefore I thank you and Happy Ferragosto Hello from A.Maurizio
Hello everyone excuse me if a few days ago I entered this request of mine
but he has the strength to try the various solutions
I managed to solve my problem by creating this solution:
Sub Write File () If you make a mistake, go to finish Dim Filename as string Dim Path as a string Dim Zone_Data as a string Dim Extensionw Come String Dim CellD as a string Dim UltimaC until Dim UltimaR until Dim NewWb as a working folder Set NewWb = Work Folders. Add File_Name = Sheet1.Range ("N2"). Value & "" 'Extension = Worksheets ("sheet1"). Range ("O2"). Value 'Path = ThisWorkbook.Path & " Attachments " & File_Name & Extension 'Data_zone = Worksheets ("sheet1"). Range ("A2: D17"). Copy dt = Format (Time, "dd-mm-yyyy") ThisWorkbook.Worksheets ("Sheet1"). Range ("A2: D17"). Copy destination: = NewWb.Worksheets (1) .Cells (1) NewWb.SaveAs File name: = ThisWorkbook.Path & " Attachments " & File_Name & "" & dt & "" & ".csv", FileFormat: = xlCSV, _ CreateBackup: = False, local: = True cell = "" 'MsgBox "Hello !!!", vbInformation, "Attention" MsgBox "Extraction completed", vbInformation, "FINISHED" finish: Well sub
And thanks to your help, everything works wonderfully.
But now what I would like to know is this:
When the file is saved in CSV it is renamed with the words that I insert in Cell (N2)
And so far everything is ok.
But if I open this file later, I notice that this term is also used to rename the CSV sheet.
Therefore I ask how this problem can be solved.
As can be seen in this image.
While I would like to take the name I enter in the Cell (P2)
Excel Sheet!
Thank you for all the help you will want to give me on this
Greetings from A.Maurizio