|
本帖最后由 zxyhyuan 于 2009-10-15 16:39 编辑
我发上来的是我们这里的文化户口册,在打印时需要一户打印在一页上,我想每页设成15行,请高手帮帮忙为谢!
用下面这段代码就可以了
Sub 打印()
Dim x As Integer
Dim myRange As Range
Dim myUnion As Range
Dim c As Range
On Error Resume Next
Sheets("文化户口册 ").Select
irow1 = Sheets("文化户口册 ").[b65536].End(xlUp).Row
For i = 1 To irow1 Step 1
If Sheets("文化户口册 ").Cells(i, 2) = "户主" Then
y = i - 14
Set myRange = Range(Cells(y, 2), Cells(i - 1, 2))
myRange.Activate
Set c = myRange.Find(What:="户主", LookIn:=xlFormulas)
c.Activate
x = c.Row
Z = i + (14 - (i - x))
If i - x < 15 Then
Set myUnion = Range(Cells(i, 1), Cells(Z, 20))
myUnion.Activate
myUnion.Select
Selection.EntireRow.Insert , CopyOrigin:=xlFormatFromLeftOrAbove
End If
End If
Next i
End Sub |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|