View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Mnilo Mnilo is offline
external usenet poster
 
Posts: 17
Default Range VBA: double entry table

Fully useful

Thank you very much Greg.
Best regards.



"Greg Wilson" escribió en el mensaje
...
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