AW: Zelladresse ermitteln
20.09.2011 12:00:16
Henrik
Hallo Frank,
hier mal was zusammen gewürfelt.
Die ertse Spalte des Arrays "arrWerteAdresse" enthält die Zelladresse, die zweite Spalte die Werte.
Per Schleife kannst du Sie entsprechend abrufen.
Sub hulu()
Dim arrWertAdresse(1 To 5, 1 To 2) As Variant, Startspalte As Long
Dim RowCount As Long, Bereich As Range, i As Integer
Dim j, t, y, condition1, sortColumn
Startspalte = 2
With ActiveSheet
RowCount = .Range("B65536").End(xlUp).Row
Set Bereich = .Range(.Cells(RowCount, Startspalte), .Cells(RowCount, 6))
For i = 1 To Bereich.Count
arrWertAdresse(i, 1) = .Cells(RowCount, Startspalte - 1 + i).Address
arrWertAdresse(i, 2) = Bereich.Value2(1, i)
Next i
End With
sortColumn = 2
For i = LBound(arrWertAdresse, 1) To UBound(arrWertAdresse, 1) - 1
For j = LBound(arrWertAdresse, 1) To UBound(arrWertAdresse, 1) - 1
condition1 = arrWertAdresse(j, sortColumn) > arrWertAdresse(j + 1, sortColumn)
If condition1 Then
For y = LBound(arrWertAdresse, 2) To UBound(arrWertAdresse, 2)
t = arrWertAdresse(j, y)
arrWertAdresse(j, y) = arrWertAdresse(j + 1, y)
arrWertAdresse(j + 1, y) = t
Next y
End If
Next
Next
End Sub
Gruß Henrik