Answer the question
In order to leave comments, you need to log in
How to convert csv using a macro?
There is such a file in csv in which there are 3 columns of data.
How to use a macro to convert it into a price list like this one on the screenshot.
That is,
1- combine the name of the first column, and combine all its data into 2 and 3 through | considering empty.
This macro does almost what you need, only it does not combine the first field into one.
Sub SaveAsCSVinQuotes()
Dim r As Range, c As Range, s As String
s = Application.GetSaveAsFilename(, "CSV Files (*.csv),*.csv,All Files (*.*),*.*", , "CSV ? |")
If s = "False" Then Exit Sub
Open s For Output As #1
s = ""
For Each r In ActiveSheet.UsedRange.columns
s_row = ""
For Each c In r.Cells
s_row = s_row & c & "|"
Next
If s = "" Then
s = s_row
Else
s = s & ";" & s_row
End If
Next
Print #1, s
Close #1
End Sub
Answer the question
In order to leave comments, you need to log in
See an example of working with the file
https://excelvba.ru/code/TextFile2Array
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question