[Visual Basic] Excel Makro erzeugt #BEZUG!

Dieses Thema im Forum "Programmierung & Entwicklung" wurde erstellt von Soji, 22. März 2012 .

Status des Themas:
Es sind keine weiteren Antworten möglich.
  1. 22. März 2012
    Excel Makro erzeugt #BEZUG!

    Hey,

    habe nun folgendes Problem - ich werte eine export Datei aus die unterschiedlich aufgebaut ist, aber immer die gleichen relevanten Daten beinhaltet.
    Um diese auswerten zu können verschiebe ich diese aus dem einen Tabellenblatt (Import) nach Daten (Daten) welche ich in sortierter Reihenfolge einfüge und von dort weiterverarbeite.

    Dies hat bisher auch geklappt, dann habe ich mir gedacht, wäre sinnvoll wenn Daten vorher vom Inhalt befreit wird... seit dem erzeugt das folgende Makro in allen Berechnungen #BEZUG! Fehler obwohl alles per $A$1 etc. angegeben wird...

    Code:
    
    Sub Import()
    '
    'KSM Import
    '
    
    'Autor: Morten Weber
    
    'screen_update_false
    Application.ScreenUpdating = False
    '/screen_update_false
    
    'AuftragsNummer
     Sheets("Import").Select
     Range("A1").Select
     On Error GoTo SkipA
     Cells.Find(What:="info3", After:=ActiveCell, LookIn:=xlFormulas, _
     LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
     MatchCase:=True, SearchFormat:=False).Activate
     Range(Selection, Selection.End(xlDown)).Select
     Selection.Cut
     Sheets("Daten").Select
     Range("A1").Select
     ActiveSheet.Paste
    SkipA:
     
    'Prüfer
     Sheets("Import").Select
     Range("A1").Select
     On Error GoTo SkipB
     Cells.Find(What:="info4", After:=ActiveCell, LookIn:=xlFormulas, _
     LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
     MatchCase:=True, SearchFormat:=False).Activate
     Range(Selection, Selection.End(xlDown)).Select
     Selection.Cut
     Sheets("Daten").Select
     Range("B1").Select
     ActiveSheet.Paste
    SkipB:
     
    'Messzeit KSM
     Sheets("Import").Select
     Range("A1").Select
     On Error GoTo SkipC
     Cells.Find(What:="measure_time1970", After:=ActiveCell, LookIn:=xlFormulas, _
     LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
     MatchCase:=True, SearchFormat:=False).Activate
     Range(Selection, Selection.End(xlDown)).Select
     Selection.Cut
     Sheets("Daten").Select
     Range("C1").Select
     ActiveSheet.Paste
    SkipC:
     
    'Artikel
     Sheets("Import").Select
     Range("A1").Select
     On Error GoTo SkipD
     Cells.Find(What:="info6", After:=ActiveCell, LookIn:=xlFormulas, _
     LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
     MatchCase:=True, SearchFormat:=False).Activate
     Range(Selection, Selection.End(xlDown)).Select
     Selection.Cut
     Sheets("Daten").Select
     Range("D1").Select
     ActiveSheet.Paste
    SkipD:
     
    'Untertype
     Sheets("Import").Select
     Range("A1").Select
     On Error GoTo SkipE
     Cells.Find(What:="info13", After:=ActiveCell, LookIn:=xlFormulas, _
     LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
     MatchCase:=True, SearchFormat:=False).Activate
     Range(Selection, Selection.End(xlDown)).Select
     Selection.Cut
     Sheets("Daten").Select
     Range("E1").Select
     ActiveSheet.Paste
    SkipE:
    
    'Wanddicke Minimum
     Sheets("Import").Select
     Range("A1").Select
     On Error GoTo SkipF
     Cells.Find(What:="wall_min", After:=ActiveCell, LookIn:=xlFormulas, _
     LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
     MatchCase:=True, SearchFormat:=False).Activate
     Range(Selection, Selection.End(xlDown)).Select
     Selection.Cut
     Sheets("Daten").Select
     Range("F1").Select
     ActiveSheet.Paste
    SkipF:
     
    'Wanddicke Mittelwert
     Sheets("Import").Select
     Range("A1").Select
     On Error GoTo SkipG
     Cells.Find(What:="wall_mean", After:=ActiveCell, LookIn:=xlFormulas, _
     LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
     MatchCase:=True, SearchFormat:=False).Activate
     Range(Selection, Selection.End(xlDown)).Select
     Selection.Cut
     Sheets("Daten").Select
     Range("G1").Select
     ActiveSheet.Paste
    SkipG:
     
    'Wanddicke Maximum
     Sheets("Import").Select
     Range("A1").Select
     On Error GoTo SkipH
     Cells.Find(What:="wall_max", After:=ActiveCell, LookIn:=xlFormulas, _
     LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
     MatchCase:=True, SearchFormat:=False).Activate
     Range(Selection, Selection.End(xlDown)).Select
     Selection.Cut
     Sheets("Daten").Select
     Range("H1").Select
     ActiveSheet.Paste
    SkipH:
     
    'Innendurchmesser Mittelwert
     Sheets("Import").Select
     Range("A1").Select
     On Error GoTo SkipI
     Cells.Find(What:="diameter_inner_mean", After:=ActiveCell, LookIn:=xlFormulas, _
     LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
     MatchCase:=True, SearchFormat:=False).Activate
     Range(Selection, Selection.End(xlDown)).Select
     Selection.Cut
     Sheets("Daten").Select
     Range("I1").Select
     ActiveSheet.Paste
    SkipI:
     
    'Außendurchmesser Minimum
     Sheets("Import").Select
     Range("A1").Select
     On Error GoTo SkipJ
     Cells.Find(What:="diameter_outer_min", After:=ActiveCell, LookIn:=xlFormulas, _
     LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
     MatchCase:=True, SearchFormat:=False).Activate
     Range(Selection, Selection.End(xlDown)).Select
     Selection.Cut
     Sheets("Daten").Select
     Range("J1").Select
     ActiveSheet.Paste
    SkipJ:
     
    'Außendurchmesser Mittelwert
     Sheets("Import").Select
     Range("A1").Select
     On Error GoTo SkipK
     Cells.Find(What:="diameter_outer_mean", After:=ActiveCell, LookIn:=xlFormulas, _
     LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
     MatchCase:=True, SearchFormat:=False).Activate
     Range(Selection, Selection.End(xlDown)).Select
     Selection.Cut
     Sheets("Daten").Select
     Range("K1").Select
     ActiveSheet.Paste
    SkipK:
     
    'Außendurchmesser Maximum
     Sheets("Import").Select
     Range("A1").Select
     On Error GoTo SkipL
     Cells.Find(What:="diameter_outer_max", After:=ActiveCell, LookIn:=xlFormulas, _
     LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
     MatchCase:=True, SearchFormat:=False).Activate
     Range(Selection, Selection.End(xlDown)).Select
     Selection.Cut
     Sheets("Daten").Select
     Range("L1").Select
     ActiveSheet.Paste
    SkipL:
    
    'Daten Reihe 1 löschen
     Sheets("Daten").Select
     Rows("1:1").Select
     Selection.Delete Shift:=xlUp
     
    'Übersicht aktivieren
     Sheets("Übersicht").Select
     
    'screen_update_false
    Application.ScreenUpdating = True
    '/screen_update_false
    
    MsgBox "Import erfolgreich!"
    
    End Sub
    
    Stehe hier etwas auf dem Schlauch da der ursprüngliche Fehlerteil .delete statt .clear ja nun komplett gelöscht ist...

    Wie verhinder ich den #BEZUG! Fehler in der Formeln?

    so far,
    Soji
     
  2. 22. März 2012
    AW: Excel Makro erzeugt #BEZUG!

    Was soll denn Selection sein? Folgende Zeile wird überall verwendet aber ich kann keine Deklaration von Selection finden. Oder bin ich blind?

    Range(Selection, Selection.End(xlDown)).Select

    Wobei ich noch dazu sagen möchte dass man das mitsicherheit auch einfacher mit ner Schleife machen kann. Aber dazu müsste man mehr über die Arbeit die das Programm verrichten soll erfahren
     
  3. 30. März 2012
    AW: Excel Makro erzeugt #BEZUG!

    Danke, hab das nun so gelöst das ich die Selection per Offset um den später zu löschenden Teil bereinigt habe... Danke und bw
     
  4. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.