-1

我在 Excel 中有一个表,其中包含列和行标题以及相应的值。如何在 Excel 中按表中的值查找列和行标题名称/索引?

在 Mathematica 中,等效函数是 Position[listoflist,value]

编辑:


我在 VBA 中做了一个简单的函数,但这远非完美

Function MathematicaPosition(lookvalue As Range, TableRange As Range, RowOrColumn As Boolean) As Integer
Dim r As Integer
Dim c As Integer
Dim tempindex As Integer
Dim i As Integer, j As Integer

tempindex = 0
r = TableRange.Rows.Count
c = TableRange.Columns.Count
For i = 1 To r
    For j = 1 To c 
        If lookvalue.Value = TableRange.Cells(i, j).Value Then
            tempindex = IIf(RowOrColumn, i, j)
        End If
    Next j
Next i
MathematicaPosition = tempindex
End Function
4

3 回答 3

0

请参阅此处的双重查找部分:

http://www.cpearson.com/Excel/TablesAndLookups.aspx

于 2013-10-01T21:27:03.673 回答
0

直接从MrExcel提升

假设数据数组在 A1:D5 中:

在 G2 中:=COUNTIF(B2:D5,G1)

在 G4 中:=IF(ROWS($G$4:G4)>$G$2,"",INDEX($A$2:$A$5,INT(SMALL(IF($B$2:$D$5=$G$1,(ROW($B$2:$D$5)-ROW($B$2)+1)*10^5+COLUMN($B$2:$D$5)-COLUMN($B$2)+1),ROWS($G$4:G4))/10^5)))

在 H4 中:=IF(ROWS($G$4:G4)>$G$2,"",INDEX($B$1:$D$1,MOD(SMALL(IF($B$2:$D$5=$G$1,(ROW($B$2:$D$5)-ROW($B$2)+1)*10^5+COLUMN($B$2:$D$5)-COLUMN($B$2)+1),ROWS($G$4:G4)),10^5)))

后两者用Ctrl++Shift输入Enter并复制下来。

我对 Mathematica 一无所知,也不明白reverse values(基本上是乘以 -1 还是切换列)。

于 2013-10-01T22:12:01.323 回答
0
Function MathematicaPosition(lookvalue As Range, TableRange As Range, RowOrColumn As Boolean) As Integer
Dim r As Integer
Dim c As Integer
Dim tempindex As Integer
Dim i As Integer, j As Integer

tempindex = 0
r = TableRange.Rows.Count
c = TableRange.Columns.Count
For i = 1 To r
    For j = 1 To c 
        If lookvalue.Value = TableRange.Cells(i, j).Value Then
            tempindex = IIf(RowOrColumn, i, j)
        End If
    Next j
Next i
MathematicaPosition = tempindex
End Function
于 2014-10-03T14:22:22.283 回答