ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
I have this code in use.
If there are no values to populate the Listbox i wish to see a Msgbox but im not sure what code to use or where to place it
If there are no values to populate the Listbox i wish to see a Msgbox but im not sure what code to use or where to place it
VBA Code:
Dim fndRng As Range
Dim firstAddress As String
With Me.ListBox1
.ColumnCount = 7
.ColumnWidths = "220;200;110;170;130;60;100"
End With
With Sheets("POSTAGE").Range("G:G")
Set fndRng = .Find(What:="RECEIVED NO SIG", LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Not fndRng Is Nothing Then
firstAddress = fndRng.Address
Do
' check the date
If Date - DateValue(fndRng.Offset(, -6)) < 80 Then
' add to listbox
With Me.ListBox1
.AddItem fndRng.Offset(, -5).Value 'CUSTOMER
.List(.ListCount - 1, 1) = fndRng.Offset(, -4).Value 'ITEM
.List(.ListCount - 1, 2) = fndRng.Offset(, -6).Value 'DATE
.List(.ListCount - 1, 3) = fndRng.Offset(, -2).Value 'TRACKING NUMBER
.List(.ListCount - 1, 4) = fndRng.Offset(, 5).Value 'CLAIM
.List(.ListCount - 1, 6) = fndRng.Value 'RECEIVED NO SIG
End With
End If
Set fndRng = .FindNext(fndRng)
Loop While Not fndRng Is Nothing And fndRng.Address <> firstAddress
End If
End With