类型不匹配数组:VBA Excel

时间:2016-07-22 17:44:57

标签: arrays excel vba excel-vba

我有一个2D数组,我想在某个列中分配字符串。我在将字符串分配给数组中特定位置的行上收到错误Type Mismatch。有什么想法吗?

Dim WinDesc() as Variant

*other code 

    ReDim Preserve WinDesc(1 To constant, 1 To 2)
    WinDesc(z, 1) = WS_Sel.Cells(1, z).Value 
    WinDesc(z, 2) = "R_counter & " / " & counter" & " products with and " _
    & C_counter & "/" & counter& " other products with" 'Errors here

1 个答案:

答案 0 :(得分:0)

这是一个关于使用/误用引号来识别字符串文字的打字错误。这应该避免不匹配错误:

WinDesc(z, 2) = R_counter & "/" & counter & " products with and " & _
                C_counter & "/" & counter & " other products with" 

已更新,以反映R_CounterC_Counter是变量。