Live-Forum - Die aktuellen Beiträge
Datum
Titel
17.10.2025 10:28:49
16.10.2025 17:40:39
16.10.2025 17:25:38
Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Excel Extract Autofit

Forumthread: Excel Extract Autofit

Excel Extract Autofit
13.07.2018 10:30:17
Christian
Moin alle zusammen,
aus meiner Datenbank möchte ich einen Excel Extrakt ziehen, dafür habe ich folgende Codestruktur aufgebaut. Bei dieser Zeile beschwert er sich:
Fehler beim Kompilieren: Sub oder Function nicht definiert. Habt ihr eine Lösung für mich :)?
 Columns("A:AL").EntireColumn.AutoFit

Private Sub Befehl98_Click()
Dim rs As DAO.Recordset ' !!Verweis auf Microsoft DAO x.x setzen !!
Dim xlApp As Object, xlWB As Object, xlSheet As Object ' Excel Objekte
Set rs = Me!Unterformular_Excel.Form.RecordsetClone ' Daten des UForms
Set xlApp = CreateObject("Excel.Application") ' Excel Instanz
xlApp.Visible = True ' Sichtbar schalten
Set xlWB = xlApp.Workbooks.Add ' Neues Workbook anlegen
Set xlSheet = xlWB.Sheets(1) ' Erstes Tabellenblatt setzen
xlSheet.Cells(2, 1).CopyFromRecordset rs ' Accessdaten in (ab) B2 schreiben
Columns("A:AL").EntireColumn.AutoFit
xlSheet.Cells(1, 1) = "Request ID"
xlSheet.Cells(1, 2) = "Area"
xlSheet.Cells(1, 3) = "Prio"
xlSheet.Cells(1, 4) = Format("Received Date", "dd.mm.yyyy")
xlSheet.Cells(1, 5) = Format("Received Time", "HH:MM")
xlSheet.Cells(1, 6) = "MSN"
xlSheet.Cells(1, 7) = "Work Order"
xlSheet.Cells(1, 8) = "IPOSCD"
xlSheet.Cells(1, 9) = "IPOITEM"
xlSheet.Cells(1, 10) = "SOP"
xlSheet.Cells(1, 11) = "KIT"
xlSheet.Cells(1, 12) = "DR & FC"
xlSheet.Cells(1, 13) = Format("Creation Date", "dd.mm.yyyy")
xlSheet.Cells(1, 14) = Format("Creation Time", "HH:MM")
xlSheet.Cells(1, 15) = "Delivery Note Number"
xlSheet.Cells(1, 16) = "AWB"
xlSheet.Cells(1, 17) = "Box"
xlSheet.Cells(1, 18) = "Request"
xlSheet.Cells(1, 19) = "Category Inbound"
xlSheet.Cells(1, 20) = "Category Production"
xlSheet.Cells(1, 21) = "Category Outbound"
xlSheet.Cells(1, 22) = Format("Validation Date", "dd.mm.yyyy")
xlSheet.Cells(1, 23) = Format("Validation Time", "HH:MM")
xlSheet.Cells(1, 24) = "Confirm CT"
xlSheet.Cells(1, 25) = Format("Starttime DBS", "HH:MM")
xlSheet.Cells(1, 26) = Format("Startdate DBS", "dd.mm.yyyy")
xlSheet.Cells(1, 27) = "Status of Request"
xlSheet.Cells(1, 28) = "Comment DBS"
xlSheet.Cells(1, 29) = "Actionholder"
xlSheet.Cells(1, 30) = "Confirm DBS"
xlSheet.Cells(1, 31) = Format("Endtime DBS", "HH:MM")
xlSheet.Cells(1, 32) = Format("Enddate DBS", "dd.mm.yyyy")
xlSheet.Cells(1, 33) = "Request Closed"
xlSheet.Cells(1, 34) = "Validation Email"
xlSheet.Cells(1, 35) = "Validation Editor"
xlSheet.Cells(1, 36) = Format("Closed Date", "dd.mm.yyyy")
xlSheet.Cells(1, 37) = Format("Closed Time", "HH:MM")
xlSheet.Cells(1, 38) = "Department"
Set db = Nothing
Set rs = Nothing
End Sub
Br
Christian
Anzeige

5
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Excel Extract Autofit
13.07.2018 11:25:48
Mike
Hi,
mit meinen bescheidenen VBA Kenntnissen nutze ich diese Zeile erfolgreich:
ActiveSheet.Columns("A:AL").EntireColumn.AutoFit
vg
Mike
AW: Excel Extract Autofit
13.07.2018 11:30:44
Christian
Leider erneut eine Fehlermeldung
Private Sub Befehl98_Click()
Dim rs As DAO.Recordset ' !!Verweis auf Microsoft DAO x.x setzen !!
Dim xlApp As Object, xlWB As Object, xlSheet As Object ' Excel Objekte
Set rs = Me!Unterformular_Excel.Form.RecordsetClone ' Daten des UForms
Set xlApp = CreateObject("Excel.Application") ' Excel Instanz
xlApp.Visible = True ' Sichtbar schalten
Set xlWB = xlApp.Workbooks.Add ' Neues Workbook anlegen
Set xlSheet = xlWB.Sheets(1) ' Erstes Tabellenblatt setzen
xlSheet.Cells(2, 1).CopyFromRecordset rs ' Accessdaten in (ab) B2 schreiben
ActiveSheet.Columns("A:AL").EntireColumn.AutoFit
xlSheet.Cells(1, 1) = "Request ID"
xlSheet.Cells(1, 2) = "Area"
xlSheet.Cells(1, 3) = "Prio"
xlSheet.Cells(1, 4) = Format("Received Date", "dd.mm.yyyy")

Anzeige
AW: Excel Extract Autofit
13.07.2018 12:24:41
mmat
Hallo Christian,
an dieser Zeile ist - mit oder ohne ActiveSheet - nix falsch. Das Problem kommt woanders her. Da mir deine Datenbank und das sonstige Umfeld nicht zur Verfügung steht, kann ich allerdings nicht viel dazu sagen.
probier mal: xlsheet.columns("A:AL").autofit
13.07.2018 12:29:14
mmat
Yeah danke :) Es klappt
13.07.2018 12:59:52
Christian
Beste Grüße
Christian
Anzeige
;

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Entdecke mehr
Finde genau, was du suchst

Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden

Suche nach den besten Antworten
Unsere beliebtesten Threads

Entdecke unsere meistgeklickten Beiträge in der Google Suche

Top 100 Threads jetzt ansehen
Anzeige