作者:乔山办公网日期:
返回目录:excel表格制作
range("a1:b4").select
range("a1").resize(4,6).select
录制宏的方式(包括打印范围选取所选择的区域),然后根据选取区域的规则修改选取区域这一部分的代码。
我这是自动找到最后e5a48de588b6e799bee5baa6e79fa5e98193333一行的,符合你的要求,请试试。
Private Sub CommandButton1_Click()
Dim row_last As Integer
Dim temp1 As Integer
Selection.SpecialCells(xlCellTypeLastCell).Select
flag = False
Do While flag = False
If ActiveCell.Row = 1 Then
Exit Do
End If
Selection.End(xlToLeft).Select
temp1 = IsEmpty(ActiveCell.Value)
Selection.End(xlToRight).Select
temp2 = IsEmpty(ActiveCell.Value)
If temp1 = True And temp2 = True Then
Selection.Offset(-1, 0).Select
Else
flag = True
Exit Do
End If
Loop
Selection.End(xlToLeft).Select
row_last = ActiveCell.Row
Range(Cells(1, 1), Cells(row_last, 1)).Select
Selection.PrintOut Copies:=1
End Sub