RE:Exportar datos a excell
prueba esté codigo recorre la tabla de donde sacas los datos que van a tu data.
Dim ApExcel As Variant
Set ApExcel = CreateObject("Excel.application")
' Hace que Excel se vea
ApExcel.Visible = True
'Agrega un nuevo Libro
ApExcel.Workbooks.Add
Dim wkbSheet As Excel.Worksheet
Dim Rng As Excel.Range
ApExcel.Cells(1, 1) = "CODIGO"
ApExcel.Cells(1, 2) = "NOMBRE PRODUCTO"
ApExcel.Cells(1, 3) = "CANTIDAD"
ApExcel.Cells(1, 4) = "FECHA INGRESO"
ApExcel.Cells(1, 5) = "STOCK ACTUAL"
ApExcel.Cells(1, 6) = "PROVEEDOR"
' Hace una Seleccion de celdas y pone bordes de Color
ApExcel.Range("A1:F1").Borders.Color = RGB(255, 0, 0)
Set Rng = ApExcel.Range("A2:" + Chr(DataGrid1.Columns.Count + 64) + CStr(Adodc1.Recordset.RecordCount))
With Adodc1.Recordset
If .BOF = False Then .MoveFirst
If .EOF = False Then
Do Until .EOF
For I = 1 To .Fields.Count
If IsDate(.Fields(I - 1)) Then
Rng.Cells(.AbsolutePosition, I) = Format(.Fields(I - 1), "mm/dd/yyyy")
Else
Rng.Cells(.AbsolutePosition, I) = .Fields(I - 1)
End If
Next I
.MoveNext
Loop
End If
End With
Set ApExcel = Nothing
Set Rng = Nothing
End Sub