Export Excel data into another Excel workbook using VBA ADODB Connection

Описание к видео Export Excel data into another Excel workbook using VBA ADODB Connection

Export Excel data into another Excel workbook using VBA ADODB Connection:

Please find the below code:

Sub ExportExcelDataintoAnotherExcel()

Dim conn As New ADODB.Connection
Dim rs As New Recordset
Dim r As Integer
Dim c As Integer

conn.Open "Provider=Microsoft.ace.oledb.12.0;Data Source=" & "C:\Users\Aakash\Desktop\New data.xlsx" & _
";Extended Properties=""Excel 12.0;HDR=yes;"";"

rs.Open "`Sheet1$`", conn, adOpenDynamic, adLockOptimistic

For r = 2 To Sheet3.Cells(Rows.Count, "A").End(xlUp).Row
rs.AddNew
For c = 0 To rs.Fields.Count - 1
rs.Fields(c).Value = Sheet3.Cells(r, c + 1).Value
Next c
rs.Update
Next r
End Sub

Комментарии

Информация по комментариям в разработке