
excel
Private Sub Worksheet_Change(ByVal Target As Range) a = Target.Row() b = Target.Column() Application.ScreenUpdating = False If a 1 Then If Cells(a, b) = "" And Cells(a - 1, b) "" Then For x = 1 To 256 If Cells(a - 1, x).HasFormula = True Then Cells(a - 1, x).Copy Cells(a, x).Select ActiveSheet.Paste Application.CutCopyMode = False End If Next x Cells(a, b).Select End If End If Application.ScreenUpdating = TrueEnd Sub
;2.在excel中,在任意位置插入一行后,该行能自动复制上一行(用VBA)Private Sub Worksheet_Change(ByVal Target As Range1) a = Target.Row() b = Target.Column() If a 1 Then If Cells(a, b) = "" And Cells(a - 1, b) "" Then Rows(a - 1 & ":" & a - 1).Copy Cells(a, b).Select ActiveSheet.Paste c = Cells(a, b) Application.CutCopyMode = False ActiveCell.FormulaR1C1 = c Cells(a, b).Select End If End IfEnd Sub
Copyright © 2025 IZhiDa.com All Rights Reserved.
知答 版权所有 粤ICP备2023042255号