Hallo Rainer,
ich glaube, ich habe es begriffen. Dummerweise bringt mich das zu einer neuen Verhaltensweise des Codes, die ich nicht verstehen kann. Das Ding sieht jetzt so aus:
Worksheets(FilStr$).Select
Do Until sscnt \> pubSSCnt Or emptycnt = 9999
emptycnt = 0
Do Until emptycnt \> 4
rr = rr + 1
cc = 1
If Trim(Worksheets(FilStr$).Cells(rr, cc).VALUE) "" Then
emptycnt = 0
If Trim(Worksheets(FilStr$).Cells(rr, 1).VALUE) = "+BV" And \_
Trim(Worksheets(FilStr$).Cells(rr, 2).VALUE) = "1012\_001" Then
ActiveBVfor1012001$ = "Y"
vaicnt = vaicnt + 1
Call CntComp(FilStr$, nextrr, rr)
End If
If Trim(Worksheets(FilStr$).Cells(rr, 1).VALUE) = "+ES" Then
emptycnt = 9999
End If
End If
Loop
sscnt = sscnt + 1
Mid$(FilStr$, Len(FilStr$), 1) = Trim(Str$(Int(sscnt)))
rr = 0
Loop
Exit Sub
End Sub
Private Sub CntComp(ByVal FilStr$, nextrr, rr)
inside = rr
Call test(inside, nextrr, FilStr$, pubRegHD1, pubRegHD2, pubRegHD3, pubRegHD4, pubRegHD5, pubRegHD6, pubRegHD7, pubRegHD8, pubRegHD9, pubRegHD10, pubRegHD11, pubRegHD12, pubwsresults)
End Sub
Private Sub test(inside, nextrr, FilStr$, pubRegHD1, pubRegHD2, pubRegHD3, pubRegHD4, pubRegHD5, pubRegHD6, pubRegHD7, pubRegHD8, pubRegHD9, pubRegHD10, pubRegHD11, pubRegHD12, pubwsresults)
inside = inside + 1
Do While Trim(Worksheets(FilStr$).Cells(inside, 1).VALUE) "+EAI" And Trim(Worksheets(FilStr$).Cells(inside, 1).VALUE) "+ES"
inside = inside + 1
If Trim(Worksheets(FilStr$).Cells(inside, 1).VALUE) = "ORD" Then
DGORD$ = Trim(Worksheets(FilStr$).Cells(inside, 2).VALUE)
End If
If Trim(Worksheets(FilStr$).Cells(inside, 1).VALUE) = "COMPCAT" Then
COMPCAT$ = Trim(Worksheets(FilStr$).Cells(inside, 2).VALUE)
End If
If Trim(Worksheets(FilStr$).Cells(inside, 1).VALUE) = "PRECL" Then
PRECL$ = Trim(Worksheets(FilStr$).Cells(inside, 2).VALUE)
End If
If Trim(Worksheets(FilStr$).Cells(inside, 1).VALUE) = "COMPLOW" Then
COMPLOW$ = Trim(Worksheets(FilStr$).Cells(inside, 2).VALUE)
End If
If Trim(Worksheets(FilStr$).Cells(inside, 1).VALUE) = "PRECU" Then
PRECU$ = Trim(Worksheets(FilStr$).Cells(inside, 2).VALUE)
End If
If Trim(Worksheets(FilStr$).Cells(inside, 1).VALUE) = "COMPUPP" Then
COMPUPP$ = Trim(Worksheets(FilStr$).Cells(inside, 2).VALUE)
End If
If Trim(Worksheets(FilStr$).Cells(inside, 1).VALUE) = "COMPAVG" Then
COMPAVG$ = Trim(Worksheets(FilStr$).Cells(inside, 2).VALUE)
End If
If Trim(Worksheets(FilStr$).Cells(inside, 1).VALUE) = "COMPEXP" Then
COMPEXP$ = Trim(Worksheets(FilStr$).Cells(inside, 2).VALUE)
End If
If Trim(Worksheets(FilStr$).Cells(inside, 1).VALUE) = "COMPLOWDEC" Then
COMPLOWDEC$ = Trim(Worksheets(FilStr$).Cells(inside, 2).VALUE)
End If
If Trim(Worksheets(FilStr$).Cells(inside, 1).VALUE) = "COMUPPDEC" Then
COMPUPPDEC$ = Trim(Worksheets(FilStr$).Cells(inside, 2).VALUE)
End If
If Trim(Worksheets(FilStr$).Cells(inside, 1).VALUE) = "COMPAVGDEC" Then
COMPAVGDEC$ = Trim(Worksheets(FilStr$).Cells(inside, 2).VALUE)
End If
If Trim(Worksheets(FilStr$).Cells(inside, 1).VALUE) = "SUBIDREF" Then
SUBIDREF$ = Trim(Worksheets(FilStr$).Cells(inside, 2).VALUE)
End If
If Trim(Worksheets(FilStr$).Cells(inside, 1).VALUE) = "SUBCATREF" Then
SUBCATREF$ = Trim(Worksheets(FilStr$).Cells(inside, 2).VALUE)
End If
'neuer loop
Loop
If vaicnt \> 1 Then
'nextrr = nextrr + 1
End If
'Sheets(pubwsresults).Select
Worksheets(pubwsresults).Cells(nextrr, pubRegHD1).VALUE = SUBIDREF$
Worksheets(pubwsresults).Cells(nextrr, pubRegHD2).VALUE = SUBCATREF$
'Worksheets(pubwsResults).Cells(nextrrpubRegHD3).VALUE = IDENTIFIER$
Worksheets(pubwsresults).Cells(nextrr, pubRegHD4).VALUE = COMPCAT$
Worksheets(pubwsresults).Cells(nextrr, pubRegHD5).VALUE = ORD$
Worksheets(pubwsresults).Cells(nextrr, pubRegHD6).VALUE = COMPAVG$
Worksheets(pubwsresults).Cells(nextrr, pubRegHD7).VALUE = COMPEXP$
Worksheets(pubwsresults).Cells(nextrr, pubRegHD8).VALUE = PRECU$
Worksheets(pubwsresults).Cells(nextrr, pubRegHD9).VALUE = COMPUPP$
Worksheets(pubwsresults).Cells(nextrr, pubRegHD10).VALUE = PRECL$
Worksheets(pubwsresults).Cells(nextrr, pubRegHD11).VALUE = COMPLOW$
Worksheets(pubwsresults).Cells(nextrr, pubRegHD12).VALUE = COMPEXCVAL$
nextrr = nextrr + 1
COMPCAT$ = ""
PRECL$ = ""
DGORD$ = ""
DGCOMPREL$ = ""
DGAFlag = ""
DGVaclid$ = ""
DGRvlid$ = ""
laufzahl = inside
Do While Trim(Worksheets(FilStr$).Cells(laufzahl, 1).VALUE) "+ES"
BAI$ = Trim(Worksheets(FilStr$).Cells(laufzahl, 1).VALUE)
estvp$ = Trim(Worksheets(FilStr$).Cells(laufzahl, 2).VALUE)
If BAI$ = "+BAI" And estvp$ = "$ESTVP" Then
inside = inside + 1
Call test(inside, nextrr, FilStr$, pubRegHD1, pubRegHD2, pubRegHD3, pubRegHD4, pubRegHD5, pubRegHD6, pubRegHD7, pubRegHD8, pubRegHD9, pubRegHD10, pubRegHD11, pubRegHD12, pubwsresults)
End If
laufzahl = laufzahl + 1
inside = laufzahl
Loop
Exit Sub
'Einschubende
End Sub
Im letzten Do…Loop komme ich irgendwann auf eine Zelle, deren Inhalt „+ES“ ist. Dann springt das Ding zu Exit Sub wie gewünscht, im nächsten Schritt aber auf das End If innerhalb des Do…Loop. Warum um Himmels Willen das denn? (nachgeprüft per schrittweiser Auaführung)
fragende Grüße,
Ralph