你试一下
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Row >= 6 And Target.Column = 27 Then
With Application
Set fp = Worksheets("发票")
Dim x%
n = --Range("w2")
m = --Range("y2")
If n > m Then
MsgBox "前面的编号小于后面的编号,请重新选择"
Exit Sub
End If
For x = n To m
Range("w2") = Application.Text(x, "00")
.ScreenUpdating = True
Names.Add Name:="Print_Area", RefersTo:="=$B$1:$U$19"
ActiveSheet.PrintOut
fp.Range("w2") = ""
Next x
End With
End If
End Sub