I'm running this search that populates a listbox, would it be possible to add a number of records returned count to the search text box?
Something like this but I'm not exactly sure how to implement it here:
Something like this but I'm not exactly sure how to implement it here:
VBA Code:
dim sMsg as string
sMsg = "Number of loaded records: " & me.controlname_countRecords
MsgBox sMsg,,"Number of records"
VBA Code:
Private Sub cmbSearch_Click()
Dim DataRange As Range, FoundCell As Range
Dim i, j As Long
Dim Search As Variant
Dim ws As Worksheet
j = 2
Do Until Sheet2.Cells(j, 1).Value = ""
j = j + 1
Loop
If j > 2 Then
Sheet2.Activate
For k = 2 To j - 1
Sheet2.Rows(2).EntireRow.Delete
Next
End If
Sheet1.Activate
Set ws = ThisWorkbook.Worksheets("Sheet1")
Search = txtSearch.Text
If Len(Search) = 0 Then Exit Sub
If IsNumeric(Search) Then Search = Val(Search)
j = 2
i = 2
Do Until Sheet1.Cells(i, 1).Text = ""
Set DataRange = ws.Range(ActiveSheet.Cells(i, 1), ActiveSheet.Cells(i, 8))
Set FoundCell = DataRange.Find(Search, LookIn:=xlValues, lookat:=xlPart)
If Not FoundCell Is Nothing Then
Sheet2.Cells(j, 1).Value = ws.Cells(i, 1)
Sheet2.Cells(j, 2).Value = ws.Cells(i, 2)
Sheet2.Cells(j, 3).Value = ws.Cells(i, 3)
Sheet2.Cells(j, 4).Value = ws.Cells(i, 4)
Sheet2.Cells(j, 5).Value = ws.Cells(i, 5)
Sheet2.Cells(j, 6).Value = ws.Cells(i, 6)
Sheet2.Cells(j, 7).Value = ws.Cells(i, 7)
Sheet2.Cells(j, 8).Value = ws.Cells(i, 8)
j = j + 1
End If
i = i + 1
Loop
Sheet2.Activate
j = 2
Do Until Sheet2.Cells(j, 1).Value = ""
j = j + 1
Loop
lstDisplay.ColumnCount = 8
lstDisplay.List = Worksheets("DATA").Range(Worksheets("DATA").Cells(2, 1), Worksheets("DATA").Cells(j, 8)).Value
'MsgBox Search & Chr(10) & "Record Not Found", 48, "Not Found"
End Sub