修改VBA函数来检索两列而不是一列的值?

我有一个函数,为单个查找值检索多个值。

Public Function MultiVLookup(MatchWith As String, TRange As Range, col_index_num As Integer) MatchWith = LCase$(MatchWith) If (MatchWith = "") Then MultiVLookup = "" Else For Each cell In TRange If LCase$(cell.Value) = MatchWith Then x = x & cell.Offset(0, col_index_num).Value & ":;" End If Next cell If (x = "") Then MultiVLookup = "" Else MultiVLookup = Left(x, Len(x) - 2) End If End If End Function 

问题是我必须从csv文件中的另一列返回另一个值。 该函数像MultiVLookup(lookup_value, table_array, col_index_number)并返回例如:

 4' X 5'-7";5'-3" X 7'-6";8' X 11'-2 

基于它匹配的项目编号。 但我需要它返回:

 4' X 5'-7":120;5'-3" X 7'-6":80;8' X 11'-2:50 

所以我需要包括:每个尺寸之间(这很容易,因为它是静态的),但我不知道如何包括每个尺寸的价格值。 所以我想我需要返回两列的值,而不是一个,例如大小和价格,而不是大小

这与我需要改变的这条线有关:

 x = x & cell.Offset(0, col_index_num).Value & ": 'WHAT TO PUT HERE!? ;" 

我只是不知道如何。 任何提示将在这里非常有帮助! 请让我知道,如果你需要更多的信息!?

我不需要一个完整的答案只是在正确的方向迈出的一步或一些有用的见解!

未经testing:

 Public Function MultiVLookup(MatchWith As String, TRange As Range, _ col_index_num As Integer, col_index_num2 As Integer) Const SEP as String = ";" Dim sp as String MatchWith = LCase$(MatchWith) If (MatchWith = "") Then MultiVLookup = "" Else sp = "" For Each cell In TRange If LCase$(cell.Value) = MatchWith Then MultiVLookup = MultiVLookup & _ sp & cell.Offset(0, col_index_num).Value & _ ":" & cell.Offset(0, col_index_num2).Value sp = SEP End If Next cell End If End Function