Hi guys, was wondering from Access , is it possible to just extract specific data only ?
my codes are as followed:
Dim rst As DAO.Recordset
Dim ApXL As Object
Dim xlWBk As Object
Dim xlWSh As Object
Dim fld As DAO.Field
Dim strPath As String
Const xlCenter As Long = -4108
Const xlBottom As Long = -4107
strPath = "C:\Tests.xls"
Dim SeriesNo As String
strTQname = "tblUnderlyingStocks"
('SeriesNo = "820"
'strTQname = "SELECT * FROM tblUnderlyingStocks WHERE Series No = SeriesNo ") <--- but i want something like this
Dim strSheetName As String
strSheetName = "Sheet1"
Set rst = CurrentDb.OpenRecordset(strTQname)
Set ApXL = CreateObject("Excel.Application")
Set xlWBk = ApXL.Workbooks.Open(strPath)
ApXL.Visible = True
Set xlWSh = xlWBk.Worksheets(strSheetName)
xlWSh.Range("A1").Select
For Each fld In rst.Fields
ApXL.ActiveCell = fld.Name
ApXL.ActiveCell.Offset(0, 1).Select
Next
rst.MoveFirst
xlWSh.Range("A2").CopyFromRecordset rst
Thank for the help in advance !