View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Greg Wilson Greg Wilson is offline
external usenet poster
 
Posts: 747
Default Range VBA: double entry table

This worked for me even though the table (named range) was in a different
worksheet. The named range ("myTable") was defined as:
=Sheet3!$C$7:$G$11

Public Function LookTable(TableName As String, ColVal As String, _
RowVal As String) As String
Dim i As Long, rw As Long, col As Long
With Range(TableName)
For i = 1 To .Columns.Count
If .Cells(1, i).Value = RowVal Then
col = i
Exit For
End If
Next
For i = 1 To .Rows.Count
If .Cells(i, 1).Value = ColVal Then
rw = i
Exit For
End If
Next
End With
LookTable = Application.Evaluate("=Index(" & TableName & "," & _
rw & "," & col & ")")
End Function

Greg