【发布时间】:2018-06-15 06:51:51
【问题描述】:
在迭代所有单元格后,我试图只打印 msgbox 的一部分。所以我只需要一次重复——所有找到的单元格只需要一次。这是整个消息框:
我只想打印消息框的这一部分:
这是代码:
Sub checkcolumns()
Dim rngCheck As Range
Dim cell As Range, j As String, mess As String
Dim TextBlockCanBeDefined, noTextBlockCanBeDefined As String
Set rngCheck = Range("B3:B6")
For Each cell In rngCheck
If IsEmpty(cell) Then
j = j & cell.Address(0, 0) & vbNewLine
If cell.Offset(, 1).Value = "L" Then
TextBlockCanBeDefined = TextBlockCanBeDefined & j & vbNewLine
ElseIf cell.Offset(, 1).Value = "T" Then
noTextBlockCanBeDefined = noTextBlockCanBeDefined & j & vbNewLine
End If
End If
Next cell
mess = vbCrLf & "For the line paragraph in row:" & vbNewLine & TextBlockCanBeDefined & "no “Text Block Row” can be defined"
mess = mess & vbCrLf & "For the table paragraph in row:" & vbNewLine & noTextBlockCanBeDefined & "is no “Text Block Row” defined"
If mess <> "" Then MsgBox mess
End Sub
【问题讨论】: