Gruppe
Matrix
Bereich
Vba
Thema
Entfernungsmatrix listen
Problem
Wie kann ich eine Entfernungsmatrix in eine Auflistung umsetzen?
Lösung
Geben Sie den nachfolgenden Code in ein Standardmodul ein und weisen Sie ihn einer Schaltfläche zu.
StandardModule: basMain
Sub MatrixListen()
Dim rng As Range
Dim iRow As Integer, iCol As Integer, iRowT As Integer
Set rng = Range("A1").CurrentRegion
With Worksheets("Liste")
For iRow = 2 To rng.Rows.Count
For iCol = 2 To rng.Rows.Count
If Not IsEmpty(Cells(iRow, iCol)) Then
iRowT = iRowT + 1
.Cells(iRowT, 1).Value = Cells(iRow, 1).Value
.Cells(iRowT, 2).Value = Cells(1, iCol).Value
.Cells(iRowT, 3).Value = Cells(iRow, iCol).Value
End If
Next iCol
Next iRow
.Select
End With
End Sub