发布网友
共1个回答
热心网友
增加针对单元格是否为合并单元格的判定range("a1").mergecells=true,并判定顶单元格是否为空值既可以Cells(ra.MergeArea.Row, ra.MergeArea.Column) = ""
昨天刚给一位提问者写过,这里也给你参考一下,希望有帮忙到
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim ra, rng As Range
Set rng = ActiveSheet.UsedRange
For Each ra In rng
a = 0
If ra.Interior.ColorIndex <> -4142 Then
If ra.MergeCells = True Then
If Cells(ra.MergeArea.Row, ra.MergeArea.Column) = "" Then
MsgBox "带颜色的填充的单元格未填充完整"
ra.Select
a = 1
Cancel = True
Exit For
End If
Else
If ra.Value = "" Then
MsgBox "带颜色的填充的单元格未填充完整"
ra.Select
a = 1
Cancel = True
Exit For
End If
End If
End If
Next
If a = 0 Then
Application.Dialogs(xlDialogPrint).Show
End If
End Sub