在 Excel VBA ROW(1:1) 中引用索引公式数组中的字符串
Referencing a string within an Index Formula Array in Excel VBA ROW(1:1)
需要一些帮助来引用索引公式数组中的字符串
我的代码如下:
Sub Loop_Test2()
Dim i As Long
Dim j As Long
Dim CountAll As Long
Dim CountXL As Long
Dim CustomerName As String
ActiveSheet.Range("A1").Activate
CountAll = ActiveSheet.Range("A35")
For j = 1 To CountAll
i = 2
CountXL = Cells(i, j).Value
R = 1
For i = 1 To CountXL
CustomerName = Cells(1, j).Value
'MsgBox CustomerName
MsgBox R
Cells(i + 2, j).FormulaArray = "=IFERROR(INDEX(Sheet2!$A:$B,SMALL(IF(Sheet2!$A:$A=""" & CustomerName & """,ROW(Sheet2!$A:$A)),ROW(R:R))*1,2),0)"
R = R + 1
Next i
Next j
End Sub
我正在尝试在这部分提供参考:
ROW(1:1)
改为:
ROW(""" & R & """ : """ & R & """)
然而收到对象错误1004
删除双引号
ROW(" & R & " : " & R & ")
已满:
Cells(i + 2, j).FormulaArray = "=IFERROR(INDEX(Sheet2!$A:$B,SMALL(IF(Sheet2!$A:$A=""" & CustomerName & """,ROW(Sheet2!$A:$A)),ROW(" & R & ":" & R & "))*1,2),0)"
举例理解:
a = 10
b = "sometext_" & a & "_sometext"
?b 立即 window (Ctrl+G) 将打印:
sometext_10_sometext
b = "sometext_""" & a & """_sometext"
将打印:
sometext_"10"_sometext
编辑器中的双引号与变量中的引号相同。
需要一些帮助来引用索引公式数组中的字符串
我的代码如下:
Sub Loop_Test2()
Dim i As Long
Dim j As Long
Dim CountAll As Long
Dim CountXL As Long
Dim CustomerName As String
ActiveSheet.Range("A1").Activate
CountAll = ActiveSheet.Range("A35")
For j = 1 To CountAll
i = 2
CountXL = Cells(i, j).Value
R = 1
For i = 1 To CountXL
CustomerName = Cells(1, j).Value
'MsgBox CustomerName
MsgBox R
Cells(i + 2, j).FormulaArray = "=IFERROR(INDEX(Sheet2!$A:$B,SMALL(IF(Sheet2!$A:$A=""" & CustomerName & """,ROW(Sheet2!$A:$A)),ROW(R:R))*1,2),0)"
R = R + 1
Next i
Next j
End Sub
我正在尝试在这部分提供参考:
ROW(1:1)
改为:
ROW(""" & R & """ : """ & R & """)
然而收到对象错误1004
删除双引号
ROW(" & R & " : " & R & ")
已满:
Cells(i + 2, j).FormulaArray = "=IFERROR(INDEX(Sheet2!$A:$B,SMALL(IF(Sheet2!$A:$A=""" & CustomerName & """,ROW(Sheet2!$A:$A)),ROW(" & R & ":" & R & "))*1,2),0)"
举例理解:
a = 10
b = "sometext_" & a & "_sometext"
?b 立即 window (Ctrl+G) 将打印:
sometext_10_sometext
b = "sometext_""" & a & """_sometext"
将打印:
sometext_"10"_sometext
编辑器中的双引号与变量中的引号相同。