VBA公式属性中的索引匹配
我一直试图通过一系列的单元格,并应用索引匹配。 所以,目前为止,索引匹配只适用于范围的第一行(所以它不循环)。 我正在提供代码。
Dim LastRow As Long Sheets("REPORT").Select LastRow = Range("A" & Rows.Count).End(xlUp).Row Range("C2:C" & LastRow).Formula "=INDEX('2609'!C:C,MATCH('REPORT'!A2,'2609'!E:E,FALSE))"
写
Range("C2:C" & LastRow).Formula "=INDEX('2609'!C:C,MATCH('REPORT'!A2,'2609'!E:E,FALSE))"
如
Range("C2:C" & LastRow).Formula ="=INDEX('2609'!C:C,MATCH('REPORT'!A2,'2609'!E:E,FALSE))"
你是缺less=
标志。
你的代码可以写成
Sub Demo() Dim ws As Worksheet Dim LastRow As Long Set ws = ThisWorkbook.Sheets("REPORT") With ws LastRow = .Range("A" & .Rows.Count).End(xlUp).Row .Range("C2:C" & LastRow).Formula = "=INDEX('2609'!C:C,MATCH('REPORT'!A2,'2609'!E:E,FALSE))" End With End Sub