tonyflora63
MIS
HI
Does anyone know how to import selective coloumns of a .csv file into an excel spread sheet?
Thanks
Tony
Does anyone know how to import selective coloumns of a .csv file into an excel spread sheet?
Thanks
Tony
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
'Connection to text directory
Set cn = CreateObject("ADODB.Connection")
strCon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Docs\;" _
& "Extended Properties=""text;HDR=Yes;FMT=Delimited"";"
cn.Open strCon
'SQL string to copy two named colums (HDR=Yes) from
'one csv file to another.
strSQL="Select ID,Field1 Into New.csv From Old.csv"
cn.Execute strSQL
'Excel
Set xl=CreateObject("Excel.Application")
xl.Workbooks.Open "C:\Docs\New.csv"
xl.Visible=True
Dim oXL
Set oXL = CreateObject("Excel.Application")
oXL.Visible = True
[green]
'Open the CSV[/green]
oXL.Workbooks.Open("C:\testcsv.csv")
[green]
' Select the undesired columns working from right to left
' then delete them one at a time[/green]
oXL.Columns("E:E").Select
oXL.Selection.Delete
oXL.Columns("B:B").Select
oXL.Selection.Delete