von hansolo » Mi, 04.07.2012 16:58
Ihr seit die Größten. Es funktioniert. ich bin begeistert. Weil ich diese Funktion so großartig finde, habe ich mir gleich gedacht, dann kann ich in einem weiteren Reiter ebenfalls mit der Eingabe einige Zeilen ausblenden. Ich habe den Code entsprechend erweitert und auch weitestgehend angepasst.
Jedoch blendet er in dem zusätzlichen Reiter nicht alle Zeilen ein, wenn ich nichts ausgewählt habe (Auswahlfeld "alle").
Hier mal der Code, was habe ich falsch gemacht?
Code: Alles auswählen
REM ***** BASIC *****
Sub ein_ausblenden (event)
sitem = event.source.selectedItem
osheet2 = thisComponent.sheets.getbyname("Tabelle2")
for i = 1 to 5
ocell = osheet2.getcellbyposition(0,i)
oStartcell1 = osheet2.getcellbyposition(1,i)
oEndcell1 = osheet2.getcellbyposition(2,i)
oStartcell2 = osheet2.getcellbyposition(3,i)
oEndcell2 = osheet2.getcellbyposition(4,i)
sText = ocell.string
if sText = sitem then
nstartrow1 = oStartcell1.value
nEndrow1 = oEndcell1.value
nstartrow2 = oStartcell2.value
nEndrow2 = oEndcell2.value
endif
next i
osheet1 = thisComponent.sheets.getbyname("Tabelle1")
ocursor = osheet1.createcursor
ocursor.gotoendofusedarea(false)
nEndusedrows = ocursor.rangeaddress.EndRow
for i = 0 to nEndusedrows
orow = osheet1.Rows(i)
orow.IsVisible = true
next i
if sitem = "alle" then exit sub
for i = nstartrow1-1 to nEndrow1-1
orow = osheet1.Rows(i)
orow.IsVisible = false
next i
if not isnull(nstartrow2) then
for i = nstartrow2-1 to nEndrow2-1
orow = osheet1.Rows(i)
orow.IsVisible = false
next i
endif
sitem = event.source.selectedItem
osheet2 = thisComponent.sheets.getbyname("Datenblatt")
for i = 1 to 5
ocell = osheet2.getcellbyposition(5,i)
oStartcell1 = osheet2.getcellbyposition(6,i)
oEndcell1 = osheet2.getcellbyposition(7,i)
oStartcell2 = osheet2.getcellbyposition(8,i)
oEndcell2 = osheet2.getcellbyposition(9,i)
sText = ocell.string
if sText = sitem then
nstartrow1 = oStartcell1.value
nEndrow1 = oEndcell1.value
nstartrow2 = oStartcell2.value
nEndrow2 = oEndcell2.value
endif
next i
osheet1 = thisComponent.sheets.getbyname("Tabelle3")
ocursor = osheet1.createcursor
ocursor.gotoendofusedarea(false)
nEndusedrows = ocursor.rangeaddress.EndRow
for i = 0 to nEndusedrows
orow = osheet1.Rows(i)
orow.IsVisible = true
next i
if sitem = "alle" then exit sub
for i = nstartrow1-1 to nEndrow1-1
orow = osheet1.Rows(i)
orow.IsVisible = false
next i
if not isnull(nstartrow2) then
for i = nstartrow2-1 to nEndrow2-1
orow = osheet1.Rows(i)
orow.IsVisible = false
next i
endif
End Sub
Ihr seit die Größten. Es funktioniert. ich bin begeistert. Weil ich diese Funktion so großartig finde, habe ich mir gleich gedacht, dann kann ich in einem weiteren Reiter ebenfalls mit der Eingabe einige Zeilen ausblenden. Ich habe den Code entsprechend erweitert und auch weitestgehend angepasst.
Jedoch blendet er in dem zusätzlichen Reiter nicht alle Zeilen ein, wenn ich nichts ausgewählt habe (Auswahlfeld "alle").
Hier mal der Code, was habe ich falsch gemacht?
[code]REM ***** BASIC *****
Sub ein_ausblenden (event)
sitem = event.source.selectedItem
osheet2 = thisComponent.sheets.getbyname("Tabelle2")
for i = 1 to 5
ocell = osheet2.getcellbyposition(0,i)
oStartcell1 = osheet2.getcellbyposition(1,i)
oEndcell1 = osheet2.getcellbyposition(2,i)
oStartcell2 = osheet2.getcellbyposition(3,i)
oEndcell2 = osheet2.getcellbyposition(4,i)
sText = ocell.string
if sText = sitem then
nstartrow1 = oStartcell1.value
nEndrow1 = oEndcell1.value
nstartrow2 = oStartcell2.value
nEndrow2 = oEndcell2.value
endif
next i
osheet1 = thisComponent.sheets.getbyname("Tabelle1")
ocursor = osheet1.createcursor
ocursor.gotoendofusedarea(false)
nEndusedrows = ocursor.rangeaddress.EndRow
for i = 0 to nEndusedrows
orow = osheet1.Rows(i)
orow.IsVisible = true
next i
if sitem = "alle" then exit sub
for i = nstartrow1-1 to nEndrow1-1
orow = osheet1.Rows(i)
orow.IsVisible = false
next i
if not isnull(nstartrow2) then
for i = nstartrow2-1 to nEndrow2-1
orow = osheet1.Rows(i)
orow.IsVisible = false
next i
endif
sitem = event.source.selectedItem
osheet2 = thisComponent.sheets.getbyname("Datenblatt")
for i = 1 to 5
ocell = osheet2.getcellbyposition(5,i)
oStartcell1 = osheet2.getcellbyposition(6,i)
oEndcell1 = osheet2.getcellbyposition(7,i)
oStartcell2 = osheet2.getcellbyposition(8,i)
oEndcell2 = osheet2.getcellbyposition(9,i)
sText = ocell.string
if sText = sitem then
nstartrow1 = oStartcell1.value
nEndrow1 = oEndcell1.value
nstartrow2 = oStartcell2.value
nEndrow2 = oEndcell2.value
endif
next i
osheet1 = thisComponent.sheets.getbyname("Tabelle3")
ocursor = osheet1.createcursor
ocursor.gotoendofusedarea(false)
nEndusedrows = ocursor.rangeaddress.EndRow
for i = 0 to nEndusedrows
orow = osheet1.Rows(i)
orow.IsVisible = true
next i
if sitem = "alle" then exit sub
for i = nstartrow1-1 to nEndrow1-1
orow = osheet1.Rows(i)
orow.IsVisible = false
next i
if not isnull(nstartrow2) then
for i = nstartrow2-1 to nEndrow2-1
orow = osheet1.Rows(i)
orow.IsVisible = false
next i
endif
End Sub[/code]