001.
Sub
Worksheet_Change(
ByVal
Target
As
Range)
002.
003.
If
Target.Address = Range(
"$E$18"
).Address
Or
Target.Address = Range(
"$F$18"
).Address
Or
Target.Address = Range(
"$G$18"
).Address
Or
Target.Address = Range(
"$H$18"
).Address
Or
Target.Address = Range(
"$I$18"
).Address
Then
004.
005.
Dim
lot
As
String
006.
007.
lot = Range(
"$E$18"
).Value
008.
009.
Dim
lot1
As
String
010.
011.
lot1 = Range(
"$F$18"
).Value
012.
013.
Dim
lot2
As
String
014.
015.
lot2 = Range(
"$G$18"
).Value
016.
017.
Dim
lot3
As
String
018.
019.
lot3 = Range(
"$H$18"
).Value
020.
021.
Dim
lot4
As
String
022.
023.
lot4 = Range(
"$I$18"
).Value
024.
025.
If
Len(lot) <= 0
Then
026.
Exit
Sub
027.
End
If
028.
029.
Dim
a
As
String
030.
Dim
x
As
String
031.
a = getLotabc(x)
032.
x = Range(
"E18:E18"
).Value
033.
034.
035.
Dim
a1
As
String
036.
Dim
x1
As
String
037.
a1 = getLotabc1(x1)
038.
x1 = Range(
"F18:F18"
).Value
039.
040.
041.
Dim
a2
As
String
042.
Dim
x2
As
String
043.
a2 = getLotabc2(x2)
044.
x2 = Range(
"G18:G18"
).Value
045.
046.
047.
Dim
a3
As
String
048.
Dim
x3
As
String
049.
a3 = getLotabc3(x3)
050.
x3 = Range(
"H18:H18"
).Value
051.
052.
053.
Dim
a4
As
String
054.
Dim
x4
As
String
055.
a4 = getLotabc4(x4)
056.
x4 = Range(
"I18:I18"
).Value
057.
058.
059.
Call
ShowMFGDate(lot)
060.
Call
ShowMFGDate1(lot1)
061.
Call
ShowMFGDate2(lot2)
062.
Call
ShowMFGDate3(lot3)
063.
Call
ShowMFGDate4(lot4)
064.
Call
ExpDate(lot)
065.
Call
ExpDate1(lot1)
066.
Call
ExpDate2(lot2)
067.
Call
ExpDate3(lot3)
068.
Call
ExpDate4(lot4)
069.
070.
End
If
071.
072.
If
Target.Address = Range(
"$E$18:$I$18"
).Address
Then
073.
If
UCase(Target.Value) = UCase(Range(
"E36:E36"
).Value)
Then
074.
075.
Range(
"E18:E18"
).Value = lot
076.
077.
End
If
078.
End
If
079.
080.
081.
If
Target.Address = Range(
"$E$18:$I$18"
).Address
Then
082.
If
UCase(Target.Value) = UCase(Range(
"E37:E37"
).Value)
Then
083.
084.
Range(
"E18:E18"
).Value = lot
085.
086.
End
If
087.
End
If
088.
089.
090.
091.
If
Target.Address = Range(
"$E$18:$I$18"
).Address
Then
092.
If
UCase(Target.Value) = UCase(Range(
"F36:F36"
).Value)
Then
093.
094.
Range(
"F18:F18"
).Value = lot
095.
096.
End
If
097.
End
If
098.
099.
100.
If
Target.Address = Range(
"$E$18:$I$18"
).Address
Then
101.
If
UCase(Target.Value) = UCase(Range(
"F37:F37"
).Value)
Then
102.
103.
Range(
"F18:F18"
).Value = lot1
104.
105.
End
If
106.
End
If
107.
108.
109.
110.
If
Target.Address = Range(
"$E$18:$I$18"
).Address
Then
111.
If
UCase(Target.Value) = UCase(Range(
"G36:G36"
).Value)
Then
112.
113.
Range(
"G18:G18"
).Value = lot
114.
115.
End
If
116.
End
If
117.
118.
119.
If
Target.Address = Range(
"$E$18:$I$18"
).Address
Then
120.
If
UCase(Target.Value) = UCase(Range(
"G37:G37"
).Value)
Then
121.
122.
Range(
"G18:G18"
).Value = lot2
123.
124.
End
If
125.
End
If
126.
127.
128.
129.
If
Target.Address = Range(
"$E$18:$I$18"
).Address
Then
130.
If
UCase(Target.Value) = UCase(Range(
"H36:H36"
).Value)
Then
131.
132.
Range(
"H18:H18"
).Value = lot
133.
134.
End
If
135.
End
If
136.
137.
138.
If
Target.Address = Range(
"$E$18:$I$18"
).Address
Then
139.
If
UCase(Target.Value) = UCase(Range(
"H37:H37"
).Value)
Then
140.
141.
Range(
"H18:H18"
).Value = lot3
142.
143.
End
If
144.
End
If
145.
146.
147.
148.
If
Target.Address = Range(
"$E$18:$I$18"
).Address
Then
149.
If
UCase(Target.Value) = UCase(Range(
"I36:I36"
).Value)
Then
150.
151.
Range(
"I18:I18"
).Value = lot
152.
153.
End
If
154.
End
If
155.
156.
157.
If
Target.Address = Range(
"$E$18:$I$18"
).Address
Then
158.
If
UCase(Target.Value) = UCase(Range(
"I37:I37"
).Value)
Then
159.
160.
Range(
"I18:I18"
).Value = lot4
161.
162.
End
If
163.
End
If
164.
165.
166.
167.
End
Sub
168.
169.
Function
ConvertDate(lot
As
String
)
As
Date
170.
Dim
nyear
As
Integer
171.
Dim
nmonth
As
Integer
172.
Dim
nday
As
Integer
173.
174.
Dim
sTmp
As
String
175.
176.
sTmp = Mid(
CStr
(VBA.Year(Now())), 1, 3)
177.
178.
nyear =
CInt
(
"0"
& sTmp & Mid(lot, 1, 1))
179.
180.
sTmp = Mid(UCase(lot), 2, 1)
181.
Select
Case
sTmp
182.
Case
"X"
183.
nmonth = 10
184.
Case
"Y"
185.
nmonth = 11
186.
187.
Case
"Z"
188.
nmonth = 12
189.
190.
Case
Else
191.
nmonth =
CInt
(
"0"
& sTmp)
192.
193.
End
Select
194.
195.
nday =
CInt
(
"0"
& Mid(lot, 3, 2))
196.
197.
Dim
dt
As
Date
198.
199.
dt = DateSerial(nyear, nmonth, nday)
200.
201.
ConvertDate = dt
202.
203.
End
Function
204.
205.
Sub
ShowMFGDate(lot
As
String
)
206.
Dim
showlot
As
String
207.
showlot = Range(
"E18:E18"
).Value
208.
If
UCase(showlot) =
"NO"
Then
209.
Range(
"E18:E18"
).Value = showlot
210.
211.
Exit
Sub
212.
End
If
213.
214.
Dim
dt
As
Date
215.
dt = ConvertDate(showlot)
216.
217.
lot = Range(
"E36:E36"
)
218.
219.
Range(
"E36:E36"
).Value = Format(dt,
"dd-MMM-YY"
)
220.
221.
End
Sub
222.
223.
Function
getLotabc(x
As
String
)
224.
Dim
a
As
String
225.
a = Range(
"E18:E18"
).Value
226.
getLotabc = a
227.
228.
End
Function
229.
230.
231.
232.
Function
ConvertDateExp(lot
As
String
)
As
Date
233.
234.
Dim
nyear
As
Integer
235.
Dim
nmonth
As
Integer
236.
Dim
nday
As
Integer
237.
238.
Dim
sTmp
As
String
239.
240.
sTmp = Mid(
CStr
(VBA.Year(Now())), 1, 3)
241.
242.
nyear =
CInt
(
"0"
& sTmp & Mid(lot, 1, 1))
243.
244.
sTmp = Mid(UCase(lot), 2, 1)
245.
Select
Case
sTmp
246.
Case
"X"
247.
nmonth = 10
248.
Case
"Y"
249.
nmonth = 11
250.
251.
Case
"Z"
252.
nmonth = 12
253.
254.
Case
Else
255.
nmonth =
CInt
(
"0"
& sTmp)
256.
257.
End
Select
258.
259.
nday =
CInt
(
"0"
& Mid(lot, 3, 2))
260.
261.
Dim
dt
As
Date
262.
263.
dt = DateSerial(nyear + 1, nmonth, nday - 1)
264.
265.
ConvertDateExp = dt
266.
267.
End
Function
268.
269.
Sub
ExpDate(lot
As
String
)
270.
271.
Dim
showlot
As
String
272.
showlot = Range(
"E18:E18"
).Value
273.
If
UCase(showlot) =
"NO"
Then
274.
Range(
"E18:E18"
).Value = showlot
275.
276.
Exit
Sub
277.
End
If
278.
279.
Dim
dt
As
Date
280.
dt = ConvertDateExp(showlot)
281.
282.
lot = Range(
"E37:E37"
)
283.
284.
Range(
"E37:E37"
).Value = Format(dt,
"dd-MMM-YY"
)
285.
286.
End
Sub
287.
288.
289.
290.
291.
Sub
ShowMFGDate1(lot1
As
String
)
292.
Dim
showlot
As
String
293.
showlot = Range(
"F18:F18"
).Value
294.
If
UCase(showlot) =
"NO"
Then
295.
Range(
"F18:F18"
).Value = showlot
296.
297.
Exit
Sub
298.
End
If
299.
300.
Dim
dt
As
Date
301.
dt = ConvertDate(showlot)
302.
303.
lot1 = Range(
"F36:F36"
)
304.
305.
Range(
"F36:F36"
).Value = Format(dt,
"dd-MMM-YY"
)
306.
307.
End
Sub
308.
309.
Function
getLotabc1(x1
As
String
)
310.
Dim
a1
As
String
311.
a1 = Range(
"F18:F18"
).Value
312.
getLotabc1 = a1
313.
314.
End
Function
315.
316.
317.
318.
319.
Function
ConvertDateExp1(lot
As
String
)
As
Date
320.
321.
Dim
nyear
As
Integer
322.
Dim
nmonth
As
Integer
323.
Dim
nday
As
Integer
324.
325.
Dim
sTmp
As
String
326.
327.
sTmp = Mid(
CStr
(VBA.Year(Now())), 1, 3)
328.
329.
nyear =
CInt
(
"0"
& sTmp & Mid(lot, 1, 1))
330.
331.
sTmp = Mid(UCase(lot), 2, 1)
332.
Select
Case
sTmp
333.
Case
"X"
334.
nmonth = 10
335.
Case
"Y"
336.
nmonth = 11
337.
338.
Case
"Z"
339.
nmonth = 12
340.
341.
Case
Else
342.
nmonth =
CInt
(
"0"
& sTmp)
343.
344.
End
Select
345.
346.
nday =
CInt
(
"0"
& Mid(lot, 3, 2))
347.
348.
Dim
dt
As
Date
349.
350.
dt = DateSerial(nyear + 1, nmonth, nday - 1)
351.
352.
353.
ConvertDateExp1 = dt
354.
355.
End
Function
356.
357.
Sub
ExpDate1(lot1
As
String
)
358.
359.
Dim
showlot
As
String
360.
showlot = Range(
"F18:F18"
).Value
361.
If
UCase(showlot) =
"NO"
Then
362.
Range(
"F18:F18"
).Value = showlot
363.
364.
Exit
Sub
365.
End
If
366.
367.
Dim
dt
As
Date
368.
dt = ConvertDateExp1(showlot)
369.
370.
371.
lot1 = Range(
"F37:F37"
)
372.
373.
Range(
"F37:F37"
).Value = Format(dt,
"dd-MMM-YY"
)
374.
375.
End
Sub
376.
377.
378.
379.
Function
ConvertDateExp2(lot
As
String
)
As
Date
380.
381.
Dim
nyear
As
Integer
382.
Dim
nmonth
As
Integer
383.
Dim
nday
As
Integer
384.
385.
Dim
sTmp
As
String
386.
387.
sTmp = Mid(
CStr
(VBA.Year(Now())), 1, 3)
388.
389.
nyear =
CInt
(
"0"
& sTmp & Mid(lot, 1, 1))
390.
391.
sTmp = Mid(UCase(lot), 2, 1)
392.
Select
Case
sTmp
393.
Case
"X"
394.
nmonth = 10
395.
Case
"Y"
396.
nmonth = 11
397.
398.
Case
"Z"
399.
nmonth = 12
400.
401.
Case
Else
402.
nmonth =
CInt
(
"0"
& sTmp)
403.
404.
End
Select
405.
406.
nday =
CInt
(
"0"
& Mid(lot, 3, 2))
407.
408.
Dim
dt
As
Date
409.
410.
dt = DateSerial(nyear + 1, nmonth, nday - 1)
411.
412.
413.
ConvertDateExp2 = dt
414.
415.
End
Function
416.
417.
Sub
ExpDate2(lot2
As
String
)
418.
419.
Dim
showlot
As
String
420.
showlot = Range(
"G18:G18"
).Value
421.
If
UCase(showlot) =
"NO"
Then
422.
Range(
"G18:G18"
).Value = showlot
423.
424.
Exit
Sub
425.
End
If
426.
427.
Dim
dt
As
Date
428.
dt = ConvertDateExp2(showlot)
429.
430.
lot = Range(
"G37:G37"
)
431.
432.
Range(
"G37:G37"
).Value = Format(dt,
"dd-MMM-YY"
)
433.
434.
End
Sub
435.
436.
437.
438.
Sub
ShowMFGDate2(lot2
As
String
)
439.
Dim
showlot
As
String
440.
showlot = Range(
"G18:G18"
).Value
441.
If
UCase(showlot) =
"NO"
Then
442.
Range(
"G18:G18"
).Value = showlot
443.
444.
Exit
Sub
445.
End
If
446.
447.
Dim
dt
As
Date
448.
dt = ConvertDate(showlot)
449.
450.
lot2 = Range(
"G36:G36"
)
451.
452.
Range(
"G36:G36"
).Value = Format(dt,
"dd-MMM-YY"
)
453.
454.
End
Sub
455.
456.
Function
getLotabc2(x2
As
String
)
457.
Dim
a2
As
String
458.
a2 = Range(
"G18:G18"
).Value
459.
getLotabc2 = a2
460.
461.
End
Function
462.
463.
464.
465.
466.
467.
Function
ConvertDateExp3(lot
As
String
)
As
Date
468.
469.
Dim
nyear
As
Integer
470.
Dim
nmonth
As
Integer
471.
Dim
nday
As
Integer
472.
473.
Dim
sTmp
As
String
474.
475.
sTmp = Mid(
CStr
(VBA.Year(Now())), 1, 3)
476.
477.
nyear =
CInt
(
"0"
& sTmp & Mid(lot, 1, 1))
478.
479.
sTmp = Mid(UCase(lot), 2, 1)
480.
Select
Case
sTmp
481.
Case
"X"
482.
nmonth = 10
483.
Case
"Y"
484.
nmonth = 11
485.
486.
Case
"Z"
487.
nmonth = 12
488.
489.
Case
Else
490.
nmonth =
CInt
(
"0"
& sTmp)
491.
492.
End
Select
493.
494.
nday =
CInt
(
"0"
& Mid(lot, 3, 2))
495.
496.
Dim
dt
As
Date
497.
498.
dt = DateSerial(nyear + 1, nmonth, nday - 1)
499.
500.
501.
ConvertDateExp3 = dt
502.
503.
End
Function
504.
505.
Sub
ExpDate3(lot3
As
String
)
506.
507.
Dim
showlot
As
String
508.
showlot = Range(
"H18:H18"
).Value
509.
If
UCase(showlot) =
"NO"
Then
510.
Range(
"H18:H18"
).Value = showlot
511.
512.
Exit
Sub
513.
End
If
514.
515.
Dim
dt
As
Date
516.
dt = ConvertDateExp3(showlot)
517.
518.
lot = Range(
"H37:H37"
)
519.
520.
Range(
"H37:H37"
).Value = Format(dt,
"dd-MMM-YY"
)
521.
522.
End
Sub
523.
524.
525.
526.
Sub
ShowMFGDate3(lot3
As
String
)
527.
Dim
showlot
As
String
528.
showlot = Range(
"H18:H18"
).Value
529.
If
UCase(showlot) =
"NO"
Then
530.
Range(
"H18:H18"
).Value = showlot
531.
532.
Exit
Sub
533.
End
If
534.
535.
Dim
dt
As
Date
536.
dt = ConvertDate(showlot)
537.
538.
lot3 = Range(
"H36:H36"
)
539.
540.
Range(
"H36:H36"
).Value = Format(dt,
"dd-MMM-YY"
)
541.
542.
End
Sub
543.
544.
Function
getLotabc3(x3
As
String
)
545.
Dim
a3
As
String
546.
a3 = Range(
"H18:H18"
).Value
547.
getLotabc3 = a3
548.
549.
End
Function
550.
551.
552.
553.
554.
Function
ConvertDateExp4(lot
As
String
)
As
Date
555.
556.
Dim
nyear
As
Integer
557.
Dim
nmonth
As
Integer
558.
Dim
nday
As
Integer
559.
560.
Dim
sTmp
As
String
561.
562.
sTmp = Mid(
CStr
(VBA.Year(Now())), 1, 3)
563.
564.
nyear =
CInt
(
"0"
& sTmp & Mid(lot, 1, 1))
565.
566.
sTmp = Mid(UCase(lot), 2, 1)
567.
Select
Case
sTmp
568.
Case
"X"
569.
nmonth = 10
570.
Case
"Y"
571.
nmonth = 11
572.
573.
Case
"Z"
574.
nmonth = 12
575.
576.
Case
Else
577.
nmonth =
CInt
(
"0"
& sTmp)
578.
579.
End
Select
580.
581.
nday =
CInt
(
"0"
& Mid(lot, 3, 2))
582.
583.
Dim
dt
As
Date
584.
585.
dt = DateSerial(nyear + 1, nmonth, nday - 1)
586.
587.
ConvertDateExp4 = dt
588.
589.
End
Function
590.
591.
Sub
ExpDate4(lot4
As
String
)
592.
593.
Dim
showlot
As
String
594.
showlot = Range(
"I18:I18"
).Value
595.
If
UCase(showlot) =
"NO"
Then
596.
Range(
"I18:I18"
).Value = showlot
597.
598.
Exit
Sub
599.
End
If
600.
601.
Dim
dt
As
Date
602.
dt = ConvertDateExp4(showlot)
603.
604.
lot = Range(
"I37:I37"
)
605.
606.
Range(
"I37:I37"
).Value = Format(dt,
"dd-MMM-YY"
)
607.
608.
End
Sub
609.
610.
611.
612.
Sub
ShowMFGDate4(lot4
As
String
)
613.
Dim
showlot
As
String
614.
showlot = Range(
"I18:I18"
).Value
615.
If
UCase(showlot) =
"NO"
Then
616.
Range(
"I18:I18"
).Value = showlot
617.
618.
Exit
Sub
619.
End
If
620.
621.
Dim
dt
As
Date
622.
dt = ConvertDate(showlot)
623.
624.
lot4 = Range(
"I36:I36"
)
625.
626.
Range(
"I36:I36"
).Value = Format(dt,
"dd-MMM-YY"
)
627.
628.
End
Sub
629.
630.
Function
getLotabc4(x4
As
String
)
631.
Dim
a4
As
String
632.
a4 = Range(
"I18:I18"
).Value
633.
getLotabc4 = a4
634.
635.
End
Function