• 20180429 xlVBA套打单据批量复制


    Sub testCopyModelRange()
        Set ModelSheet = ThisWorkbook.Worksheets("单据模板")
        Set PrintSheet = ThisWorkbook.Worksheets("批量打印")
        CopyModelRange ModelSheet, PrintSheet, 2
    End Sub
    Public Sub CopyModelRange(ByVal ModelSheet As Worksheet, ByVal PrintSheet As Worksheet, ByVal CopyTime As Long)
        Dim ModelRng As Range '模板单元格
        Dim modelRowHeight() As Double '模板行高数据
        Dim desRng As Range '粘贴位置
        Dim i As Long '行号
        
        With ModelSheet
            If Application.WorksheetFunction.Count(.Cells) > 0 Then
                '计数防止计算行号发生错误
                EndRow = .Cells.Find("*", .Cells(1, 1), xlValues, xlWhole, xlByRows, xlPrevious).Row + 1
                EndCol = .Cells.Find("*", .Cells(1, 1), xlValues, xlWhole, xlByColumns, xlPrevious).Column
                '获取单据模板单元格区域
                Set ModelRng = .Range(.Cells(1, 1), .Cells(EndRow, EndCol))
                Debug.Print ModelRng.Address
            Else
                MsgBox "模板为空!"
                Exit Sub
            End If
        End With
        
        
        With PrintSheet
            .Cells.Clear
            '批量复制单据模板
            For i = 1 To CopyTime
                If Application.WorksheetFunction.Count(.Cells) = 0 Then
                    Set desRng = .Range("A1")
                Else
                    EndRow = .Cells.Find("*", .Cells(1, 1), xlValues, xlWhole, xlByRows, xlPrevious).Row + 2
                    Set desRng = .Cells(EndRow, 1)
                End If
                ModelRng.Copy desRng
            Next i
        End With
        
        
    End Sub
    

      

  • 相关阅读:
    测分用例模板
    功能测试用例设计(24方法)
    pycharm
    Mac-peizhi
    基于Java BufferedImage实现识别图片中的黑色矩形
    Soap从入门到实战
    实列+JVM讲解类的实列化顺序
    基于Springboot的BaseService和BaseController
    Kendo-Grid for Vue API and Template
    web项目jsp中无法引入js问题
  • 原文地址:https://www.cnblogs.com/nextseven/p/8970702.html
Copyright © 2020-2023  润新知