ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
Hi,
I have a working code which looks for a value "DELIVERED NO SIG" from todays date & back for 90 days.
I am looking to edit this code so it looks for the value starting from 30 days of todays date & then back 60 days.
So from todays date October 28th the code would start to look for the value from September 28th to July 28th
Originaly straight from todays date & back 90 didnt go to plan so needs to be as mentioned above
@NoSparks does this make sense to you,Thanks
Code shown below
I have a working code which looks for a value "DELIVERED NO SIG" from todays date & back for 90 days.
I am looking to edit this code so it looks for the value starting from 30 days of todays date & then back 60 days.
So from todays date October 28th the code would start to look for the value from September 28th to July 28th
Originaly straight from todays date & back 90 didnt go to plan so needs to be as mentioned above
@NoSparks does this make sense to you,Thanks
Code shown below
VBA Code:
Private Sub UserForm_Initialize()
Dim fndRng As Range
Dim firstAddress As String
Dim cnt As Long
With Me.ListBox1
.ColumnCount = 7
.ColumnWidths = "220;195;110;170;130;50;100"
'220;200;110;170;130;60;100"
End With
With Sheets("POSTAGE").Range("G:G")
Set fndRng = .Find(What:="DELIVERED 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
[COLOR=rgb(184, 49, 47)]If Date - DateValue(fndRng.Offset(, -6)) < 90 Then[/COLOR]
cnt = cnt + 1
' 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
If cnt = 0 Then
MsgBox "THERE ARE " & cnt & " RECORDS FOR WITHIN THE LAST 80 DAYS", vbInformation, "DELIVERED BUT NO SIGNATURE MESSAGE"
End
End If
Me.StartUpPosition = 0
Me.Top = Application.Top + 100 ' MARGIN FROM TOP OF SCREEN
Me.Left = Application.Left + Application.Width - Me.Width - 70 ' LEFT / RIGHT OF SCREEN
End Sub