VBA公式自动填充参考.md 2.1 KB

Sub 公式向下填充()
Dim n, a, b
n = ActiveCell.CurrentRegion.Rows.Count
'判断活动单元格所在表的行数下限
a = ActiveCell.Row
b = ActiveCell.Column
==Selection.AutoFill Destination:=Range(Cells(a, b), Cells(n, b))==
End Sub > 来自 <https://www.linkedin.com/pulse/%E5%85%AC%E5%BC%8F%E8%87%AA%E5%8A%A8%E5%90%91%E4%B8%8B%E5%A1%AB%E5%85%85excel-vba-junmin-wu?trk=pulse-det-nav_art>

参考文献2 https://www.linkedin.com/pulse/%E5%85%AC%E5%BC%8F%E8%87%AA%E5%8A%A8%E5%90%91%E4%B8%8B%E5%A1%AB%E5%85%85excel-vba-junmin-wu?trk=pulse-det-nav_art

Sub 插入列以及自动填充公式()

Columns("P:P").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("Q:Q").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("R:R").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("P1").Select
ActiveCell.FormulaR1C1 = "首报"
Range("Q1").Select
ActiveCell.FormulaR1C1 = "二报"
Range("R1").Select
ActiveCell.FormulaR1C1 = "三报"
Range("P2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=RC[-3]-27"
Range("Q2").Select
ActiveCell.FormulaR1C1 = "=RC[-4]-20"
Range("R2").Select
ActiveCell.FormulaR1C1 = "=RC[-5]-10"
'Range("P2:R2").Select
'Selection.AutoFill Destination:=Range("P2:R9573")
==Range("P2").AutoFill Destination:=Range("P2:P" & Range("A65536").End(xlUp).Row)==
==Range("Q2").AutoFill Destination:=Range("Q2:Q" & Range("A65536").End(xlUp).Row)==
==Range("R2").AutoFill Destination:=Range("R2:R" & Range("A65536").End(xlUp).Row)==
'Range("P2:R9573").Select
End Sub

参考文献1 http://club.excelhome.net/thread-1330801-1-1.html