首页 热点资讯 义务教育 高等教育 出国留学 考研考公

Excel VBA合并单元格颜色填充打印?

发布网友

我来回答

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

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com