- ©«¤l
- 1447
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1471
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-12-5
|
¦^´_ 13# Andy2483
ÁÂÁ«e½ú¦A¦^ÂÐ
«á¾Ç§â ·j´M¸ê®Æ®w¨M©w³æ¸¹½Æ²ß¨Ãµù¸Ñ¤F¤@¤U!
«á¾Ç¤]¬OÂǥѳo¤@¥DÃD¾Ç¨ìÅܼƪº«Å§i±N¦r¦ê»P¼Æ¦r°µÅÜ´«
ÁÂÁ«e½úµoªí¦¹¥DÃD»P½d¨Ò
¥H¤U¤ß±o¨Ñ«e½ú°Ñ¦Ò
Sub ·j´M¸ê®Æ®w¨M©w³æ¸¹()
'¡õ¼Æ¦r»P¦r¦ê¥i¥H¥Ñ¤@¶}©lªº«Å§i´N¨M©w³oÅܼƬO¦r¦ê©Î¼Æ¦r!
Dim Arr, T, xA, xB, xC, N, Mx&, D1$, O1$, D2&, O2&, M1$, M2&
'¡ô«Å§iÅܼÆ
Set xA = Sheets("¸ê®Æ¿é¤J")
'¡ô¥OxA¬O "¸ê®Æ¿é¤J" ¤u§@ªí
Set xB = Sheets("¥X³f¸ê®Æ")
'¡ô¥OxB¬O "¥X³f¸ê®Æ" ¤u§@ªí
Set xC = Sheets("¸ê®Æ®w")
'¡ô¥OxA¬O "¸ê®Æ®w" ¤u§@ªí
If xB.Cells(Rows.Count, "B").End(3).Row > 1 Then
'¡ô¦pªG "¥X³f¸ê®Æ" ³Ì«á¤@¦C¦C¼Æ¤j©ó1 !
xB.Activate
'¡ôµe±´N¸õ¨ì "¥X³f¸ê®Æ" ¤u§@ªí
MsgBox "ªº¥X³f¸ê®Æ¥¼³B²z!"
Exit Sub
'¡ô¥X²{´£¥Ü!µ²§ôµ{¦¡!
End If
O1 = xA.[B2]: O2 = O1
'¡ô¥OO1³oÅܼƬO "¸ê®Æ¿é¤J" ¤u§@ªí.[B2] ¦r¦ê
'¡ô¥OO2³oÅܼƬO O1ÅܼÆÂà¾ã¼Æ
M1 = xC.Cells(Rows.Count, "B").End(3)
'¡ô¥OM1³oÅܼƬO "¸ê®Æ®w" ¤u§@ªí.BÄæ³Ì«á¨ºÀx¦s®æ ¦r¦ê
M2 = M1
'¡ô¥OM2³oÅܼƬO M1ÅܼÆÂà¾ã¼Æ
D1 = Format(Date, "yymmdd")
'¡ô¥OD1¬O¤µ¤Ñ¤é´Á²Õ¦¨ªº¦r¦ê¨Ò¦p22/10/11 Âন "221011"
D2 = D1 & "001"
'¡ô¥OD2¬O ²Õ¦¨¤µ¤é²Ä¤@µ§¥X³f³æªº§Ç¸¹(¼Æ¦r)
If InStr(M1, D1) Then
'¡ô¦pªGM1¦r¦ê¦³¥]§tD1¦r¦ê
xA.[B2] = M2 + 1
'¡ô±ø¥óY¦¨¥ß!¥Nªí "¸ê®Æ®w" ¤u§@ªí¤w¸g¦³¤µ¤Ñªº§Ç¸¹
'¡ôM2¬O¼Æ¦r´N+1 ¶ñ¨ì "¸ê®Æ¿é¤J" ¤u§@ªíªº.[B2]
xA.[B2].Interior.ColorIndex = xlNone
'¡ô¥O "¸ê®Æ¿é¤J" ¤u§@ªíªº.[B2]©³¦âµL¦â
xA.[B2].Font.ColorIndex = 1
'¡ô¥O "¸ê®Æ¿é¤J" ¤u§@ªíªº.[B2]¦r¦â¬O¶Â¦â
Else
xA.[B2] = D2
'¡ô§_«h¥Nªí¤µ¤ÑÁÙ¨S¦³¦s¤J¤µ¤Ñªº¥X³f³æ
'¡ô"¸ê®Æ¿é¤J" ¤u§@ªíªº.[B2] ´NÅý¥L¬O¤µ¤Ñªº²Ä¤@µ§§Ç¸¹D2
xA.[B2].Interior.ColorIndex = xlNone
'¡ô¥O "¸ê®Æ¿é¤J" ¤u§@ªíªº.[B2]©³¦âµL¦â
xA.[B2].Font.ColorIndex = 1
'¡ô¥O "¸ê®Æ¿é¤J" ¤u§@ªíªº.[B2]¦r¦â¬O¶Â¦â
End If
End Sub |
|