For each Blatt in This... klappt nicht warum
31.01.2006 17:24:25
baronf
holgendes Makro klappt bei mir nicht!!
Warum? In den Variablen stehen keine Werte und das Makro wechselt das Blatt nicht!!
Wo ist mein Fehler?
Gruss Fredike
Sub DB_Füllen()
Dim cur As Variant
Dim Datum As Variant
Dim KA As Variant
Dim KST As Variant
Dim KABEZ As Variant
Dim KSTBEZ As Variant
Dim Betrag As Variant
Dim Bezeichnung As Variant
Dim Blatt As Worksheet
Workbooks("xy.xls").Activate
For Each Blatt In ThisWorkbook.Worksheets
'**** Prüfen, ob E1 mit Sternchen gefüllt ist
If Cells(1, 5).Value = "*" Then GoTo weiter
Tabname = ActiveSheet.Name
Var = Cells(1, 5).Value
If Var = "" Then
For i = 40 To 100 '2 to 100
cur = Blatt.Cells(i, 2).Value
Datum = Blatt.Cells(i, 3).Value
Betrag = Blatt.Cells(i, 4).Value
Bezeichnung = Blatt.Cells(i, 5).Value
KA = Blatt.Cells(i, 6).Value
KABEZ = Blatt.Cells(i, 7).Value
KST = Blatt.Cells(i, 9).Value
KSTBEZ = Blatt.Cells(i, 10).Value
'Soll hier schreiben!!!!!
If (Datum <> "" And cur <> "" And Betrag <> "" And Bezeichnung <> "" And KA <> "" And KABEZ <> "" And KST <> "" And KSTBEZ <> "" And cur <> "Currency") Then
Workbooks("Datenbank.xls").Activate
Worksheets("Datenbank").Select
t = Columns(1).Find("").Row
Cells(t, 1).Value = cur
Cells(t, 2).Value = Datum
Cells(t, 3).Value = Betrag
Cells(t, 4).Value = Bezeichnung
Cells(t, 5).Value = KA
Cells(t, 6).Value = KABEZ
Cells(t, 7).Value = ""
Cells(t, 8).Value = KST
Cells(t, 9).Value = KSTBEZ
Workbooks("Finance_Report_2006.xls").Activate
Worksheets(Tabname).Activate 'Zurück in aktuelle Tabellenblatt
End If
Next i
End If
Cells(1, 5).Value = "*"
weiter:
Workbooks("XY.xls").Activate
Next Blatt
'wenn Daten eingetragen sind in die Zelle E1 ein * setzen
End Sub