AW: Wertepaare ermitteln
09.02.2016 14:58:33
Michael
Hallo Jens,
versuch's mal damit:
Sub Wertepaare()
On Error GoTo Fehler
Dim TB1, TB2, i%, z%, Wmax&, Gmax%
Application.ScreenUpdating = False
'*** Stammdaten Anfang
Set TB1 = Sheets("Tabelle1")
Set TB2 = Sheets("Tabelle2")
z = 2
' Gmax = -999999
With TB2
.Cells.ClearContents
.Cells(1, 1) = "Wert": .Cells(1, 2) = "Ergebnis"
For i = TB1.Range("B3") To TB1.Range("B4")
TB1.Cells(1, 2) = i
.Cells(z, 1) = i
.Cells(z, 2) = TB1.Cells(2, 2)
If i = TB1.Range("B3") Then Gmax = Abs(.Cells(z, 2)): Wmax = TB1.Cells(1, 2)
If Abs(TB1.Cells(2, 2)) > Gmax Then
Gmax = TB1.Cells(2, 2)
Wmax = TB1.Cells(1, 2)
End If
z = z + 1
Next
TB1.Cells(1, 2) = Wmax
End With
Application.ScreenUpdating = False
'*** Fehlerbehandlung
Err.Clear
Fehler:
If Err.Number 0 Then MsgBox "Fehler: " & Err.Number & vbLf & Err.Description: Err.Clear
Application.ScreenUpdating = False
End Sub
Schöne Grüße,
Michael