This function will allow you to return the cross reference of a row title and column header:
Function CrossReference(RowTitle, ColTitle, DataRange As Range) As Variant
Dim FindRow As Range, FindCol As Range
Set FindRow = DataRange.Columns(1).Find(RowTitle, lookat:=xlWhole)
Set FindCol = DataRange.Rows(1).Find(ColTitle, lookat:=xlWhole)
If FindRow Is Nothing Or FindCol Is Nothing Then
CrossReference = ""
Else
CrossReference = DataRange.Cells(FindRow.Row, FindCol.Column).Value
End If
End Function
And here's a simple example sub calling it:
Sub Test()
MsgBox CrossReference("test3", "example4", ThisWorkbook.Sheets(1).Cells)
End Sub
Bookmarks