En løsning med en brugerdefineret function:
https://www.dropbox.com/s/c06y1rtaj1d77x5/lokationsopslag%20%281%29.xlsm?dl=0Koden:
Option Explicit
Function HentLocation(Opslag As Variant, OpslagMatrix As Range, OutputMatrix As Range, OutputNr As Integer) As Variant
With Application
.Volatile
.Calculate
End With
Dim Arr1() As Variant, Arr2 As Variant
Dim Row As Integer, Column As Integer, Test As Integer
HentLocation = ""
Arr1 = OpslagMatrix
Arr2 = OutputMatrix
Test = 0
For Row = LBound(Arr1, 1) To UBound(Arr1, 1)
If Arr1(Row, 1) = Opslag.Value Then
For Column = LBound(Arr1, 2) + 1 To UBound(Arr1, 2)
If Arr1(Row, Column) <> "" Then
Test = Test + 1
If Test = OutputNr Then
HentLocation = Arr2(1, Column)
End If
End If
Next
End If
Next
End Function
Jan