我正在尝试将数据从源工作表复制到另一个工作表,直到最后一行数据。如何将宏限制到最后一行数据。下面是为获取数据而创建的宏。
' Sub ABringData() ' ' BringData 宏 ' ' Sub ABringData()
Columns("G:G").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("G1").Select
ActiveCell.FormulaR1C1 = "=Data!RC[-4]"
Range("G2").Select
Columns("G:G").EntireColumn.AutoFit
Range("G1").Select
Selection.AutoFill Destination:=Range("G:G")
Range("G:G").Select
Columns("G:G").EntireColumn.AutoFit
Columns("G:G").Select
With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With
Columns("AA:AA").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("AA1").Select
ActiveWindow.SmallScroll ToRight:=1
ActiveCell.FormulaR1C1 = "=Data!RC[-20]"
Range("AA1").Select
Selection.AutoFill Destination:=Range("AA:AA")
Range("AA:AA").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With
ActiveWindow.SmallScroll ToRight:=-12
Columns("G:G").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("G4").Select
结束子