Ich möchte alle Zeilen 3-154 ausgeblendet haben, außer jene die ich mit der Maus markiert habe.
Könnte mir bitte dazu jemand helfen?
Gruß
Heinz
Sub Nichtselektierte_Zeilen_ausblenden()
Dim rngRow As Range
For Each rngRow In ActiveSheet.Rows("3:154")
If Intersect(rngRow, Selection.Rows) Is Nothing Then
rngRow.Hidden = True
End If
Next
End Sub
Grußschalöte die Bildwschirmakltualisierung ab und am Ende wieder ein.
Private Sub CommandButton7_Click()
'Sub Nichtselektierte_Zeilen_ausblenden()
Application.ScreenUpdating = False
Dim rngRow As Range
For Each rngRow In ActiveSheet.Rows("3:154")
If Intersect(rngRow, Selection.Rows) Is Nothing Then
rngRow.Hidden = True
End If
Next
Call BlattSchutz_Ein
Application.ScreenUpdating = True
End Sub
Option Explicit
Private Sub CommandButton1_Click()
Dim rngX As Range, rngC As Range, rngE As Range
For Each rngX In Selection.EntireRow.Areas
Set rngC = ComplementRect(rngX)
If Not rngC Is Nothing Then
If rngE Is Nothing Then
Set rngE = rngC
Else
Set rngE = Intersect(rngE, rngC)
End If
End If
Next rngX
Set rngE = Intersect(rngE, Range(Rows(3), Rows(154)))
If Not rngE Is Nothing Then
rngE.EntireRow.Hidden = True
End If
End Sub
kommt als Code in Modul1
Option Explicit
'********************************************************
'Code ist von Erich aus Kamp-Lintfort *
'********************************************************
Function ComplementRect(rngA As Range) As Range
Dim zv As Long, zb As Long, sv As Long, sb As Long, rngT As Range
zv = rngA.Row
zb = zv + rngA.Rows.Count - 1
sv = rngA.Column
sb = sv + rngA.Columns.Count - 1
If zv > 1 Then Set rngT = Range(Rows(1), Rows(zv - 1))
If zb < Rows.Count Then
If rngT Is Nothing Then
Set rngT = Range(Rows(zb + 1), Rows(Rows.Count))
Else
Set rngT = Union(rngT, Range(Rows(zb + 1), Rows(Rows.Count)))
End If
End If
If sv > 1 Then
If rngT Is Nothing Then
Set rngT = Range(Cells(zv, 1), Cells(zb, sv - 1))
Else
Set rngT = Union(rngT, Range(Cells(zv, 1), Cells(zb, sv - 1)))
End If
End If
If sb < Columns.Count Then
If rngT Is Nothing Then
Set rngT = Range(Cells(zv, sb + 1), Cells(zb, Columns.Count))
Else
Set rngT = Union(rngT, Range(Cells(zv, sb + 1), Cells(zb, Columns.Count)))
End If
End If
Set ComplementRect = rngT
End Function
Gruß Tino rngE.EntireRow.Hidden = True
Private Sub CommandButton7_Click()
Dim rngX As Range, rngC As Range, rngE As Range
For Each rngX In Selection.EntireRow.Areas
Set rngC = ComplementRect(rngX)
If Not rngC Is Nothing Then
If rngE Is Nothing Then
Set rngE = rngC
Else
Set rngE = Intersect(rngE, rngC)
End If
End If
Next rngX
Set rngE = Intersect(rngE, Range(Rows(3), Rows(154)))
If Not rngE Is Nothing Then
rngE.EntireRow.Hidden = True
End If
End Sub