View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jamie Collins Jamie Collins is offline
external usenet poster
 
Posts: 593
Default 'Group by' facility?

SW wrote:
Treating it as a Jet SQL source sounds useful. How do I do that?


Sub just_four_lines()
Dim rs As Object
Set rs = CreateObject("ADOR.Recordset")
rs.Open _
"SELECT COUNT(*) as customer_count," & _
" Country FROM MyFile#csv" & _
" GROUP BY Country" & _
" ORDER BY COUNT(*), Country", _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\MyFolder\;" & _
"Extended Properties='Text;HDR=Yes';"
Sheet1.Range("A1").CopyFromRecordset rs
End Sub

For more details <g, see:

http://msdn.microsoft.com/library/de...ng03092004.asp

Jamie.

--