我正在使用Do Until ()
公式将vlookup公式粘贴到“活动”单元格中。
我使用“ i”作为变量来更改单元格行。在vlookup公式的间接函数中调用“ i”时,不能使用它。我认为我使用的双引号不正确。请帮忙!
Sub Overtime()
Dim i As Integer
Dim Rws As Long, Rng As Range, c As Range
i = 6
Do Until (Cells(i, 3) = Active)
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromRightOrBelow
Range("E" & i) = "=vlookup($A" & i & ",indirect(""'""&$H$3&""'!A:AZ""),1,FALSE)"
Range("F" & i) = "=vlookup($A" & i & ",indirect(""'""&$H$3&""'!A:AZ""),2,FALSE)"
Range("G" & i) = "=vlookup($A" & i & ",indirect(""'""&$H$3&""'!A:AZ""),3,FALSE)"
***Range("H" & i) = "=vlookup($H$3,indirect(""'[ATTENDANCE.xlsm]$G""" & i & """'!A:AZ""),35,FALSE)"***
Range("I" & i) = "=vlookup($A" & i & ",indirect(""'""&$H$3&""'!A:AZ""),7,FALSE)"
Range("J" & i) = "=vlookup($A" & i & ",indirect(""'""&$H$3&""'!A:AZ""),28,FALSE)"
Range("K" & i) = "=vlookup($A" & i & ",indirect(""'""&$H$3&""'!A:AZ""),36,FALSE)"
i = i + 1
Loop
End Sub
我希望单元格H6中的公式为“活动”单元格
=VLOOKUP($H$3,INDIRECT("'[ATTENDANCE.xlsm]"&$G6&"'!A:AZ"),35,FALSE)
应该在下一个单元格(如G7,G8等)中自动填充范围“ G6”,直到单元格(i,3)处于活动状态