Excel录制宏怎样实现单元格自动填充,看图。
如图,P列用了VLOOKUP函数公式,录制宏想实现,P列自动填充,以A列行数为准。一下是录制宏代码,请大神帮忙修改。Range("P2").SelectActiveCel...
如图,P列用了VLOOKUP函数公式,录制宏想实现,P列自动填充,以A列行数为准。一下是录制宏代码,请大神帮忙修改。Range("P2").Select ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[3],工具!C[-15]:C[-11],4,0)" Selection.AutoFill Destination:=Range("P2:P95880") Range("P2:P145880").Select Range("Q2").Select ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[2],工具!C[-16]:C[-15],2,0)" Selection.AutoFill Destination:=Range("Q2:Q95880") Range("Q2:Q95880").Select Range("T2").Select ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],工具!C[-19]:C[-15],5,0)" Selection.AutoFill Destination:=Range("T2:T95880") Range("T2:T95880").Select Columns("U:W").Select Selection.ClearContents Range("V8").Select ActiveWindow.SmallScroll Down:=-3End Sub
展开
1个回答
展开全部
Sub FormulaTest()
Dim lastrow As Long
lastrow = ActiveSheet.Cells(Cells.Rows.Count, 1).End(xlUp).Row
Range("P2:P" & lastrow).FormulaR1C1 = "=VLOOKUP(RC[3],工具!C[-15]:C[-11],4,0)"
Range("Q2:Q" & lastrow).FormulaR1C1 = "=VLOOKUP(RC[2],工具!C[-16]:C[-15],2,0)"
Range("T2:T" & lastrow).FormulaR1C1 = "=VLOOKUP(RC[-1],工具!C[-19]:C[-15],5,0)"
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询