2020-03-11考勤宏(公开)

Sub insert_check()

    Dim i   As Integer
    Dim Int_row   As Integer
    Dim Int_Row_Total   As Integer
    
    Int_row = 5
    
    ' 表示的就是在A列从第65536行(不包含第65536行)向上查找到的第一个有数据的单元格.
    Int_Row_Total = Worksheets("月度汇总").Range("A65536").End(xlUp).Row
    
    For i = 4 To Int_Row_Total
        
        ' 选择第一个要处理的行
        Rows(Int_row).Select
        ' 插入行
        Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
        ' 在插入行中合并指定区域并填入文字
        Range("B" & Int_row & ":AM" & Int_row).Select
        With Selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            .WrapText = True
            .Orientation = 0
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = False
            .ReadingOrder = xlContext
            .MergeCells = False
        End With
        Selection.Merge
        ActiveCell.FormulaR1C1 = _
            "记录考勤扣款:事假(       )天,病假(        )天,探亲假(         )天,迟到(         )次,早退(        )次,旷工(        )天,保胎假(    )天。其他备注"
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .ThemeColor = xlThemeColorDark1
            .TintAndShade = -0.249977111117893
            .PatternTintAndShade = 0
        End With
        Range("A" & (Int_row - 1) & ":A" & Int_row).Select
        Range("A" & Int_row).Activate
        With Selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            .WrapText = True
            .Orientation = 0
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = False
            .ReadingOrder = xlContext
            .MergeCells = False
        End With
        Selection.Merge
        Int_row = Int_row + 2
    Next
    
 '   ActiveWindow.ScrollRow = Int_row - 4
 '   ActiveWorkbook.Save
End Sub

你可能感兴趣的:(2020-03-11考勤宏(公开))