silentwolf
Well-known Member
- Joined
- May 14, 2008
- Messages
- 1,216
- Office Version
- 2016
Hi guys,
I am trying to export from Access to Excel ...
All is working but now I am not sure how to go further..
I like to format Column C;D;E, in hh:mm after after the Header so all Rows from C2,D2,E2 to end of rows in hh:mm format.
I got the transfer worked out but not sure how to work with the columns..
Could someone let me know please.. I am sure it is not that difficult but I cant seam to get my head around this..
Thanks for looking!
Albert
I am trying to export from Access to Excel ...
All is working but now I am not sure how to go further..
I like to format Column C;D;E, in hh:mm after after the Header so all Rows from C2,D2,E2 to end of rows in hh:mm format.
I got the transfer worked out but not sure how to work with the columns..
Code:
Sub HoleDatenVonExcel()
Dim appExcel As Excel.Application
Dim wbkExcel As Excel.Workbook
Dim wksExcel As Excel.Worksheet
Dim rngExcel As Excel.Range
Dim rcsExport As Recordset
Dim fldExport As Field
Dim intSpalte As Integer
Dim lngRow As Long
Set rcsExport = CurrentDb.OpenRecordset("tblObjMitarbeiter")
Set appExcel = HoleAnwendung("Excel.Application")
If appExcel Is Nothing Then
MsgBox "Kein Excel gefunden!,", vbCritical, p_cstrAppTitel
Else
appExcel.Visible = True
Set wbkExcel = appExcel.Workbooks.Add()
Set wksExcel = wbkExcel.Worksheets(1)
'Spalten werden formatiert
For intSpalte = 1 To rcsExport.Fields.Count
With wksExcel.Cells(1, intSpalte)
.Value = rcsExport.Fields(intSpalte - 1).Name
.Interior.Color = vbGreen
End With
Next
[B]''How do I need to change this ?? So it will format each of the rows after Row 1 in the hh:mm format[/B]
' For lngRow = 1 To rcsExport.Fields.Count
' With wksExcel.Cells(1, lngRow)
' .Value = rcsExport.Fields(lngRow - 1).Item
' .Interior.Color = vbGreen
' End With
' Next
Set rngExcel = wksExcel.Range("A2")
rngExcel.CopyFromRecordset rcsExport
End If
appExcel.Visible = True
End Sub
Could someone let me know please.. I am sure it is not that difficult but I cant seam to get my head around this..
Thanks for looking!
Albert