populate values in a cell based on date criteria

mogss_04

Board Regular
Joined
May 9, 2019
Messages
57
Hi All,

I required assistance on the below. Would be great if someone could help me out with it.

I have the below file.

https://www.dropbox.com/s/5wzide7bso...%203.xlsx?dl=0

I have to look at the below columns
I - Usage , column L - Batch creation Date , M - Batch Expiry Date and N - Inventory Flag

There is a coulmn name "Usage - I" which has the below 7 categories data . So 1st case we need to filter first by "Unrestriced use" and "Unrestricted-Use Mat" and then need to filter column "M - Batch Expiry Date". So if the expiry date falls 12 months after the the current month i.e 2020 June onwards then column N should be polpulated as"Usable (>12)", if expiry date falls between 7 - 12 months after expiry date
which is from December 2019 - May 2020 then column N should be polpulated as"Usable (7-12)" . Under "Unrestriced use" and "Unrestricted-Use Mat" anything before May 2019 that is current month should be populated as
"Expired" and if expiry date is from " May 2019 - November 2019" then column N should be poulated as "Near expiry".
Next we need to filter by "Blocked Stock" under column I and if it is Blocked stock then column N should be populated as Blocked irrespective of the expiry date column - M . Similary if column I is "Transit and Intransit" then column N should be populated as "Transit".Similary if column I is "Transit and Intransit" then column N should be populated as "Transit".Quality inspection - to be populated as "Quality inspection" under column N irrespective of expiry date
Valuated Goods Receipt Blocked Stock- to be populated as "Blocked" under column N irrespective of expiry date




1 Unrestricted Use
2. Transit
3.Blocked Stock
4.Unrestricted-Use Mat
5. Intransit
6.Quality inspection
7.Valuated Goods Receipt Blocked Stock


When " Batch Expiry Date" is blank or # we need to look at the "Batch Creation Date" column which is column "L" and the same rules apply. Exactly the same as expiry date rules except this goes 1 year back.


which is June 2018 onwards - Usable (>12)
Dec 2017 - May 2018 - Usable (7-12)
May 2017- Nov 2017 - Near Expiry
Before May 2017 -




If Manufacturing date and expiry date both are blanks or # present in both then N column should be poulated as Usable > 12.


Let me know how can we code the above and automate this procedure.
 
Hi Dante,

Even if we take todays date as calculation. All the dates beyond 10th June should be classified as "Usable >12 ".

However the below dates are still classified as "
Usable (7-12)"

[TABLE="width: 64"]
<colgroup><col width="64" style="width:48pt"> </colgroup><tbody>[TR]
[TD="class: xl63, width: 64"]30.06.2020[/TD]
[/TR]
[TR]
[TD="class: xl63"]15.06.2020[/TD]
[/TR]
[TR]
[TD="class: xl63"]19.06.2020[/TD]
[/TR]
[TR]
[TD="class: xl63"]21.06.2020[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hi Dante,

Even if we take todays date as calculation. All the dates beyond 10th June should be classified as "Usable >12 ".

However the below dates are still classified as "
Usable (7-12)"

[TABLE="width: 64"]
<tbody>[TR]
[TD="class: xl63, width: 64"]30.06.2020[/TD]
[/TR]
[TR]
[TD="class: xl63"]15.06.2020[/TD]
[/TR]
[TR]
[TD="class: xl63"]19.06.2020[/TD]
[/TR]
[TR]
[TD="class: xl63"]21.06.2020[/TD]
[/TR]
</tbody>[/TABLE]

Remember that it takes June as a base, but it takes from June 1.
 
Upvote 0
Exactly perfect. If it takes 1st June. Then these dates should be falling under category ""Usable >12 " as per the calcualtions. But instead it is falling under ""Usable (7-12)".Please check post #26 . You agreed on my understanding of rules that anything beyond 1st June 2020 comes under """Usable >12 "All the below 4 dates fall beyond 1st June 2020.

30.06.2020
15.06.2020
19.06.2020
21.06.2020

But its not happening this way. Can you please hence check on above.



 
Upvote 0
Exactly perfect. If it takes 1st June. Then these dates should be falling under category ""Usable >12 " as per the calcualtions. But instead it is falling under ""Usable (7-12)".Please check post #26 . You agreed on my understanding of rules that anything beyond 1st June 2020 comes under """Usable >12 "All the below 4 dates fall beyond 1st June 2020.

30.06.2020
15.06.2020
19.06.2020
21.06.2020

But its not happening this way. Can you please hence check on above.


This is the part of the code.

Code:
 wDate = Format(DateSerial(Year(Date), Month(Date) + [COLOR=#ff0000]6[/COLOR], 1), "mm/dd/yyyy")
    fin = Day(DateSerial(Year(Date), Month(Date) + 12, 1) - 1)
    wDat2 = Format(DateSerial(Year(Date), Month(Date) +[COLOR=#ff0000] 12 - 1[/COLOR], fin), "mm/dd/yyyy")
    sh.Range("B1").AutoFilter Field:=12, Criteria1:=">=" & wDate, Criteria2:="<=" & wDat2
    If sh.Range("B" & Rows.Count).End(xlUp).Row > 2 Then _
        sh.Range("N2:N" & lr).Value = "Usable (7-12)"
    
    wDate = Format(DateSerial(Year(Date), Month(Date) + [COLOR=#ff0000]12[/COLOR], 1), "mm/dd/yyyy")
    sh.Range("B1").AutoFilter Field:=12, Criteria1:=">=" & wDate
    If sh.Range("B" & Rows.Count).End(xlUp).Row > 2 Then _
        sh.Range("N2:N" & lr).Value = "Usable (>12)"



Change the month number, for example:
Code:
 wDate = Format(DateSerial(Year(Date), Month(Date) + [COLOR=#FF0000]6[/COLOR], 1), "mm/dd/yyyy")
    fin = Day(DateSerial(Year(Date), Month(Date) + 12, 1) - 1)
    wDat2 = Format(DateSerial(Year(Date), Month(Date) +[COLOR=#FF0000] 10[/COLOR], fin), "mm/dd/yyyy")
    sh.Range("B1").AutoFilter Field:=12, Criteria1:=">=" & wDate, Criteria2:="<=" & wDat2
    If sh.Range("B" & Rows.Count).End(xlUp).Row > 2 Then _
        sh.Range("N2:N" & lr).Value = "Usable (7-12)"
    
    wDate = Format(DateSerial(Year(Date), Month(Date) + [COLOR=#FF0000]12[/COLOR], 1), "mm/dd/yyyy")
    sh.Range("B1").AutoFilter Field:=12, Criteria1:=">=" & wDate
    If sh.Range("B" & Rows.Count).End(xlUp).Row > 2 Then _
        sh.Range("N2:N" & lr).Value = "Usable (>12)"

or

Code:
 wDate = Format(DateSerial(Year(Date), Month(Date) + [COLOR=#FF0000]6[/COLOR], 1), "mm/dd/yyyy")
    fin = Day(DateSerial(Year(Date), Month(Date) + 12, 1) - 1)
    wDat2 = Format(DateSerial(Year(Date), Month(Date) +[COLOR=#FF0000] 10[/COLOR], fin), "mm/dd/yyyy")
    sh.Range("B1").AutoFilter Field:=12, Criteria1:=">=" & wDate, Criteria2:="<=" & wDat2
    If sh.Range("B" & Rows.Count).End(xlUp).Row > 2 Then _
        sh.Range("N2:N" & lr).Value = "Usable (7-12)"
    
    wDate = Format(DateSerial(Year(Date), Month(Date) + [COLOR=#FF0000]11[/COLOR], 1), "mm/dd/yyyy")
    sh.Range("B1").AutoFilter Field:=12, Criteria1:=">=" & wDate
    If sh.Range("B" & Rows.Count).End(xlUp).Row > 2 Then _
        sh.Range("N2:N" & lr).Value = "Usable (>12)"
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,264
Members
452,627
Latest member
KitkatToby

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