JumboCactuar
Well-known Member
- Joined
- Nov 16, 2016
- Messages
- 788
- Office Version
- 365
- Platform
- Windows
Hi,
I have been using this but recently it fails with an error - something about the file is locked by an exclusive user.
Is there any alternative you would suggest? Maybe just Autofilter but not sure how to set the criteria
Thanks in advance
I have been using this but recently it fails with an error - something about the file is locked by an exclusive user.
Is there any alternative you would suggest? Maybe just Autofilter but not sure how to set the criteria
VBA Code:
Sub sbADO()
Dim Conn As New ADODB.Connection
Dim mrs As New ADODB.Recordset
Dim DBPath As String, sconnect As String
Application.ScreenUpdating = False
DBPath = ThisWorkbook.FullName
MYSQL = "SELECT * From [Data$] WHERE RANGE=1 AND ITEM LIKE 'SC%' ORDER BY FILENAME ASC" '
sconnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBPath _
& ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";"
Conn.Open sconnect
mrs.Open MYSQL, Conn
Sheet2.Range("A2").CopyFromRecordset mrs
mrs.Close
Conn.Close
End Sub
Thanks in advance