Good day guys!
I writing you because of my problem. I don't know how to write the macro witch will help me. Please help me with my problem.
So situation is that I have several hundreds of data documents in .csv files with all text and numbers are inserted in A column and for outside of excel program I only need 257 and 263 column witch separated with commas ( ,). And I need only two columns of many and all the rows of that specific columns. Also I need to make macro with will open one file - deletes the rest or copies to other file and closes and opens next one. I think it is called "loop"? I have some kind of loop made by my self but it is not perfect :D
For example :
File a:
text,text,3452,text,text,232.232,text,hello,world,123, .... ,257,abc,abc,123,text,text,263,text,123,....
File b:
text,text,3452,text,text,232.232,text,hello,world,123, .... ,257,abc,abc,123,text,text,263,text,123,....
File abcdef:
text,text,3452,text,text,232.232,text,hello,world,123, .... ,257,abc,abc,123,text,text,263,text,123,....
andding the created loop (i call it like this) of converting the needed files to other format.
I will order beer for fella witch will help me!
I writing you because of my problem. I don't know how to write the macro witch will help me. Please help me with my problem.
So situation is that I have several hundreds of data documents in .csv files with all text and numbers are inserted in A column and for outside of excel program I only need 257 and 263 column witch separated with commas ( ,). And I need only two columns of many and all the rows of that specific columns. Also I need to make macro with will open one file - deletes the rest or copies to other file and closes and opens next one. I think it is called "loop"? I have some kind of loop made by my self but it is not perfect :D
For example :
File a:
text,text,3452,text,text,232.232,text,hello,world,123, .... ,257,abc,abc,123,text,text,263,text,123,....
File b:
text,text,3452,text,text,232.232,text,hello,world,123, .... ,257,abc,abc,123,text,text,263,text,123,....
File abcdef:
text,text,3452,text,text,232.232,text,hello,world,123, .... ,257,abc,abc,123,text,text,263,text,123,....
andding the created loop (i call it like this) of converting the needed files to other format.
VBA Code:
ublic Sub ConvertXmlToXlsx()
Application.DisplayAlerts = False
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
xmlFolder = Worksheets("xml_to_csv").Range("B1").Value
convFolder = Worksheets("xml_to_csv").Range("B2").Value
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(xmlFolder)
For Each objFile In objFolder.Files
If UCase(Right(objFile.Name, Len(XML))) = UCase(XML) Then
NewFileName = convFolder & objFile.Name & "_conv.csv"
Set ConvertThis = Workbooks.Open(objFolder & "\" & objFile.Name)
ConvertThis.SaveAs Filename:=NewFileName, FileFormat:= _
xlCSV
ConvertThis.Close
Columns(7).EntireColumn.Delete
End If
Next objFile
End Sub
I will order beer for fella witch will help me!