Dim adoCN As ADODB.Connection Dim sConnString As String Dim sSQL As String Dim lRow As Long, lCol As Long sConnString = "Provider=sqloledb;Server=;Database=mycon;User Id=;Password=" Set adoCN = CreateObject("ADODB.Connection") adoCN.Open sConnString 'Assumes that you have Field1, Field2 and Field3 in columns A, B and C 'For this example we can assume that the data exists on Sheet1, with a header on row '1 and data in rows 2-11 'Also assume that the fields are defined as character (e.g. varchar or char) 'Text values must be enclosed in apostrophes whereas numeric values should not. 'adoCN.Open For lRow = 1 To ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row sSQL = "SELECT * INTO TestTable FROM Sheets(1)$" ***adoCN.Execute sSQL*** Next lRow adoCN.Close Set adoCN = Nothing 'On Error GoTo 0
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)