View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Nate Oliver[_3_] Nate Oliver[_3_] is offline
external usenet poster
 
Posts: 71
Default filter with vb code

Hello Dan,

Speaking of Access, using ADO might make some sense with such a quandary.
Here's an example that creates a new workbook in c:\temp\ named Book1.xls:

Sub ExToEx()
Dim cn As Object
Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
ThisWorkbook.FullName & ";Extended Properties=Excel 8.0;"
cn.Execute "SELECT Col1, Col2 INTO [Excel
8.0;Database=c:\temp\book1.xls].[Sheet1]" _
& " FROM [Sheet1$a:b] Where Col2 = " & Sheets(2).Range("a1").Value
cn.Close: Set cn = Nothing
End Sub

Where Col1 and Col2 are column headers located in row 1 of Sheet1, and the
variable is located in the 2nd Sheet, A1. The workbook that your running this
from must be saved so that a proper connection can be established.

More info can be found on such an approach he
http://support.microsoft.com/kb/295646/EN-US/

Regards,
Nate Oliver