Schleife beenden
Verfasst: Mo 22. Jun 2020, 20:10
Hallo, wie man am Code wahrscheinlich sehen kann bin ich ein absoluter Anfänger. Mein Problem liegt jetzt bei Zeile 32. Und zwar kann es sein das die Variable "oInhalt7" mir 0 zurückgibt und ich dann im Satz danach einen Laufzeitfehler bekomme. Meine Vermutung wäre jetzt das ich die Schleife zurückspringen lassen muss um in die nächste Runde zu gelangen. Ich hab aber keine Ahnung wie ich das zurückstelle.
Kann mir da jemand helfen............ ?
Gruß Marcus
Code: Alles auswählen
sub main
dim oDesktop
dim oDoc
dim osheet
odoc=thiscomponent
oSheet = ThisComponent.sheets.getByName("Bedarfsplan")
'Suche feste Inhalte
oInhalt = "Geräteleistung"
oInhalt1 = "pca22"
'oFunctionAccess = createUnoService( "com.sun.star.sheet.FunctionAccess" )
'oInhalt=inputbox("Erste Suchbegriff")
'oInhalt1=inputbox("sweite Suchbegriff")
x = oSheet.Columns(1).queryEmptyCells()
z = x(x.Count-1).RangeAddress.StartRow
for n = 2 to z
oReturn = oSheet.getCellRangeByName("B"+ n)
oInhalt2 = oReturn.getstring()
If oInhalt2 = oInhalt Then
oReturn1 = oSheet.getCellRangeByName("T"+ n)
oInhalt3 = oReturn1.getstring()
oInhalt7 = InSTR(1,oInhalt3,oInhalt1)
oInhalt8 = mid(oInhalt3,oInhalt7,5)
if oInhalt8 = oInhalt1 Then
oRange = oSheet.getCellRangeByName("A"+n+":Y"+n)
oDoc.CurrentController.Select(oRange)
oRangeAddress = oDoc.CurrentController.getTransferable
x = oSheet.Columns(45).queryEmptyCells()
z1 = x(x.Count-1).RangeAddress.StartRow
oCell = oSheet.getCellRangeByName("AF"+(z1+1))
oDoc.CurrentController.Select(oCell)
oDoc.CurrentController.insertTransferable(oRangeAddress)
end If
end If
next
End Sub
Gruß Marcus