AW: MAX
08.12.2021 05:34:33
Oraculix
Falls ich Dich richtig verstehe möchtest Du Tabelle2 Spalte B nach dem Höchsten Wert oben haben.
Hier mal ein Beispiel bei Doppelklick in Zellle B1 wird abwechselnd sortiert von 1-1000 oder von 1000-1
Kopiere diesen Code in Tabelle 2
Option Explicit
Dim my_sort As Boolean
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim Bereich1 As Range
Dim LSpalte As Integer
Dim lzeile As Long
Dim SelectHeadline As Variant
LSpalte = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Column
lzeile = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row
Set Bereich1 = Range(Cells(1, 1), Cells(1, LSpalte))
If Intersect(Target, Bereich1) Is Nothing Then
Exit Sub
Else
If my_sort Then
SelectHeadline = ActiveCell.Address(RowAbsolute:=False, columnAbsolute:=False)
Range(Cells(1, 1), Cells(lzeile, LSpalte)).Sort Key1:=Range(SelectHeadline), Order1:=xlAscending, Header:= _
xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
my_sort = False
Else
SelectHeadline = ActiveCell.Address(RowAbsolute:=False, columnAbsolute:=False)
Range(Cells(1, 1), Cells(lzeile, LSpalte)).Sort Key1:=Range(SelectHeadline), Order1:=xlDescending, Header:= _
xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
my_sort = True
End If
End If
Application.Calculation = xlCalculationAutomatic
Range("B2").Select
Application.ScreenUpdating = True
End Sub
Gruß
Oraculix