Excluding items older than one year

tomleitch

Board Regular
Joined
Jan 3, 2012
Messages
189
Hi all,


I have some code that I am using to import data from scripting dictionary array items.

I am trying to get it to ignore items that have a date older than one year but it does not seem to like the code. I'm not sure why and wondering if anyone can help.

Below is a small excerpt of some of the code

Code:
 NxtRw = Ws1.Range("A" & Rows.Count).End(xlUp).Offset(1).Row      For Each Ky In .keys


        If .Item(Ky)(3) <> "CAN" And .Item(Ky)(3) <> "COMP" And .Item(Ky)(5).Value < (Date + 365) Then
         Ws1.Range("A" & NxtRw).Value = Ky
         Ws1.Range("A" & NxtRw).Interior.Color = rgbYellow
         Ws1.Range("B" & NxtRw).Value = .Item(Ky)(0)
        On Error Resume Next
         Ws1.Range("B" & NxtRw).ClearComments
            On Error GoTo 90
            If .Item(Ky)(6) <> "" Then
         Ws1.Range("B" & NxtRw).AddComment
         Ws1.Range("B" & NxtRw).Comment.Text Text:=.Item(Ky)(6)
         Ws1.Range("B" & NxtRw).Comment.Shape.TextFrame.AutoSize = True
         If Ws1.Range("B" & NxtRw).Comment.Shape.Width > 200 Then


I know it's the bit that has And
Code:
And .Item(Ky)(5).Value < (Date + 365) Then
that's giving me the trouble but I'm not sure why.

.Item(Ky)(5) is my date value


Any help appreciated,

Many thanks
Tom
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,943
Messages
6,181,913
Members
453,071
Latest member
Gizmo2024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top