我正在尝试创建一个弹出窗口,只要列E大于1,就会返回整行数据或只返回前3列。棘手的部分是,当“关闭”按钮位于单击另一个收集数据的弹出窗口。
到目前为止,我只能通过使用循环让它在单独的弹出窗口中返回每个记录,但我想在同一个弹出窗口中显示所有情况。这就是我所拥有的:
列A是姓氏 B列是名字 列C是位置编号 D列是日期 E列是一个简单的计数单元格,显示名字和姓氏出现的次数
Private Sub cmdClose_Click()
Dim wsx As Worksheet
Set wsx = Worksheets("SuspectData")
Dim xRow As Long
Dim countingX As Integer
countingX = 2
'find last row in database'
xRow = wsx.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row
'prompt warning'
With wsx
Do While countingX <= xRow
If Range("E" & countingX) > 1 Then
MsgBox ("Suspect " & Range("B" & countingX) & " " & Range("A" & countingX) & " at Unit " & Range("C" & countingX))
End If
countingX = countingX + 1
Loop
End With
Unload Me
End Sub
谢谢!
答案 0 :(得分:0)
如果您希望所有案例都在一个弹出窗口内返回,您应该将案例添加到字符串中,并让弹出窗口调用循环外的字符串
Dim s as String
s = ""
Do While countingX <= xRow
If Range("E" & countingX) > 1 Then
s = s & vbnewline & "Suspect " & Range("B" & countingX) & " " & Range("A" & countingX) & " at Unit " & Range("C" & countingX)
End If
countingX = countingX + 1
Loop
MsgBox s