DELETE range of cells with ADO

User avatar
sal21
PlatinumLounger
Posts: 4339
Joined: 26 Apr 2010, 17:36

DELETE range of cells with ADO

Post by sal21 »

I conect a sheet via ADO with:

Code: Select all

Dim CNN As ADODB.Connection
Dim RST As ADODB.Recordset
Dim SQL As String

Set CNN = New ADODB.Connection
Set RST = New ADODB.Recordset

CNN.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\REPORT_L0928\BUSCEMI.xls;" & _
"Extended Properties=""Excel 8.0;HDR=Yes"";"
I need to delete with * all cells in the range A2:H2500 of sheet "TEST"... how to?

User avatar
HansV
Administrator
Posts: 78378
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: DELETE range of cells with ADO

Post by HansV »

ADO doesn't work that way. You can run a Delete query

DELETE * FROM ... WHERE ...

but you can't refer to a range such as A2:H5200. You'd do that in Excel itself.
Best wishes,
Hans