LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default To create a macro to fetch data from excel sheet (2003) using a qu

Hi

I need help to create a macro in excel 2003. The macro should fetch data
from excel sheet using a query, as the data in sheet is more than 35000 lines
using for loop of while loop takes more time to search data.
I am using following code for fetching data but no success (Please help
me to run it)

Code:-
Sub Testquery2()
Dim strQuery As String
Dim cn As ADODB.Connection
Dim rsT As ADODB.Recordset

Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0;Data"
.ConnectionString = "Driver={Microsoft Excel Driver (*.xls)};" &
"DBQ=" & Application.Path & "\Variance Calculation.xls;"
.Open
End With

strQuery = "SELECT * FROM [DB_OL & Act input $]"

Set rsT = New ADODB.Recordset
rsT.CursorLocation = adUseClient
rsT.Open strQuery, cn
adOpenStatic , adLockOptimistic, adCmdText

If (rsT.RecordCount < 0) Then
MsgBox "Query Success"
End If

rsT.Close
cn.Close
End Sub

Please help me to get the way.

Thanks & Regards,
Atul D. Pohankar
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
fetch a value from a w/sheet to userform. tkraju via OfficeKB.com Excel Programming 2 May 5th 09 02:23 AM
fetch values from w/sheet TUNGANA KURMA RAJU Excel Discussion (Misc queries) 0 April 2nd 09 03:43 AM
Fetch Access data from Excel [email protected] Excel Programming 1 October 31st 06 07:53 PM
fetch data from excel page Mark[_64_] Excel Programming 1 May 21st 06 04:09 PM
Use of Indirect function to fetch data from another Excel file Boon8888 Excel Worksheet Functions 1 January 20th 06 07:46 PM


All times are GMT +1. The time now is 11:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"