zoukankan      html  css  js  c++  java
  • 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
    

      

  • 相关阅读:
    安装JDK,如何配置PATH,如何配置CLASSPATH
    存储过程笔记
    用BeanFactoryAware接口,用BEAN的名称来获取BEAN对象
    静态工厂实例代码
    setTimeout 和 setInterval 的区别
    Spring Autowire自动装配
    动态工厂模式代码实例
    JS处理回车事件
    不错的Spring学习笔记(转)
    单例模式要点
  • 原文地址:https://www.cnblogs.com/nextseven/p/8970702.html
Copyright © 2011-2022 走看看