Я работаю над окном поиска Excel VBA. Как я могу разместить окно сообщения, если записи не найдены в списке?
Private Sub CommandButton2_Click()
Me.TextBox1.Value = UCase(Me.TextBox1.Value)
Dim sh As Worksheet
Set sh = Sheets("Sheet1")
Dim i As Long
Dim x As Long
Dim P As Long
Me.ListBox1.Clear
For i = 2 To sh.Range("F" & Rows.Count).End(xlUp).Row
For x = 1 To Len(sh.Cells(i, 6))
P = Me.TextBox1.TextLength
If LCase(Mid(sh.Cells(i, 6), x, P)) = Me.TextBox1 And Me.TextBox1 <> "" Then
With Me.ListBox1
.AddItem sh.Cells(i, 1)
.List(ListBox1.ListCount - 1, 1) = sh.Cells(i, 2)
.List(ListBox1.ListCount - 1, 2) = sh.Cells(i, 3)
.List(ListBox1.ListCount - 1, 3) = sh.Cells(i, 4)
.List(ListBox1.ListCount - 1, 4) = sh.Cells(i, 5)
.List(ListBox1.ListCount - 1, 5) = sh.Cells(i, 6)
.List(ListBox1.ListCount - 1, 6) = sh.Cells(i, 7)
.List(ListBox1.ListCount - 1, 7) = sh.Cells(i, 8)
End With
End If
Next x
Next i
r = Sheet1.Columns("A").ColumnWidth * 7
ListBox1.ColumnWidths = "70;60;80;230;230;100;60;" & r & ";"
End Sub