单一标准INDEX MATCH具有连接标准

时间:2017-04-24 06:40:54

标签: excel-vba indexing match vba excel

我在VBA中遇到以下Index/Match公式时遇到问题。

以下是代码

Sub MSTitl_box()

Dim Target As Range
Dim x As Variant
Dim y As Variant
Dim z As Variant
Dim refdate As Variant
Dim discat As Variant
Dim Milestone As Variant
Dim criteria As Variant

Set Target = ActiveSheet.Range(ActiveCell.Address)

x = Target.Column - 2    
y = Target.Row - 2

refdate = Application.WorksheetFunction.Index(Range("C2:AF2"), x)    
discat = Application.WorksheetFunction.Index(Range("B3:B23"), y)    
z = discat & refdate    
criteria = Formula = "=MATCH(" & z & ",msrng,0)"  
Milestone = Formula = "=INDEX(colm_mstitle_rng," & criteria & ",0)"

MsgBox criteria

End Sub

变量refdate是日期值,格式为“m / d / yyyy”& discat是一个文本字符串。

z显示x&的正确连接值年。但是当它转到MATCH公式时,它表示FALSE,随后索引公式失败。

我认为它与变量定义有关。

0 个答案:

没有答案