- ©«¤l
- 1446
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1470
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-10-21
|
¦^´_ 8# ã´£³¡ªL
ÁÂÁ«e½ú
¤À¬q¾Ç²ß¤ß±oµù¸Ñ¦p¤U,½Ð«e½ú¦A«ü¾É
Private Sub Cmd_A1_Click() '«Ø¥ß±ø½X¼g¤J«ö¶s
Dim TT$, T$, V%, VV%, R&, i&, Arr, xF As Range
'¡ô«Å§iÅܼÆ:(TT,T)¬O¦r¦êÅܼÆ,(V,VV)¬Oµu¾ã¼ÆÅܼÆ,(R,i)¬Oªø¾ã¼ÆÅܼÆ,
'Arr¬O³q¥Î«¬ÅܼÆ,xF¬OÀx¦s®æÅܼÆ
Un = 0: Call Àˬd¿é¤JÈ
'¡ô¥OUn³oµu¾ã¼ÆÅܼƬO 0 :°õ¦æ Àˬd¿é¤JÈ °Æµ{¦¡
If zK = "A00000" Then MsgBox "¡¯©|¥¼¿é¤J¥ô¦ó¸ê®Æ! ": Exit Sub
'¡ô¦pªGzK³o¦r¦êÅܼƬO "A00000"!´N¸õ¥X´£¥Üµ¡~ :µ²§ôµ{¦¡°õ¦æ
If zK = "A22222" Then MsgBox "¡¯½s¿è¤º®e»Pì¸ê®Æ¬Û¦P¡A¥¼Åܧó¡I ": Exit Sub
'¡ô¦pªGzK³o¦r¦êÅܼƬO "A22222"!´N¸õ¥X´£¥Üµ¡~ :µ²§ôµ{¦¡°õ¦æ
If InStr(zK, "0") Then MsgBox "¡¯¸ê®Æ¿é¤J¤£§¹¥þ©Î¿ù»~¡A½ÐÀˬd! ": Exit Sub
'¡ô¦pªGzK³o¦r¦êÅܼƸ̦³¥]§t"0"¦r¤¸!´N¸õ¥X´£¥Üµ¡~ :µ²§ôµ{¦¡°õ¦æ
zDay = Now: If zMode = 2 Then zDay = Lab_Date.Caption
'¡ô¥OzDay³o³q¥Î«¬ÅܼƬO²{¦b®É¶¡ :¦pªGzModeÅܼƬO 2!´N¥OzDayÅܼƬO Lab_Date¼ÐÅÒ¦^¶ÇÈ
TT = Format(zDay, "mmdd") & Join(Yrr, "")
'¡ô¥OTT³o¦r¦êÅܼƬO zDayÅܼÆÂà´«¦r¦ê¨ú¤ë¤ë¤é¤é4½X,³s±µ(YrrÅܼƥHªÅ¦r¤¸µ²¦X¦¨ªº¦r¦ê)
'---------------------------
If zMode = 2 Then '½s¿è§ó§ï--§R°£ì¸ê®Æ
'¡ô¦pªGzModeÅܼƬO 2?
Set xF = Sheets("Database").Range("G:G").Find(TextBox5.Text, Lookat:=xlWhole)
'¡ô¥OxF³oÀx¦s®æÅܼƬO¥H Find()¤èªk¦^¶ÇªºÀx¦s®æª«¥ó:
'¿é¤Jµ¡TextBox5¤å¦r¬O n·j´Mªº¸ê®Æ,·j´M½d³ò¬O "Database"¤u§@ªíGÄæ,±ø¥ó:È¥þ³¡¬Û¦P
If Not xF Is Nothing Then xF.EntireRow.Delete
'¡ô¦pªGxFÅܼƦ³·j´M¨ì!´N¥OxFÅܼƩҦbªº¦C§R°£,Àx¦s®æ·|©¹¤W»¼¸É
End If
With Sheets("Database")
'¡ô¥H¤U¬OÃö©ó "Database"¤u§@ªí ªºµ{§Ç
R = .Cells(Rows.Count, 1).End(3).Row
'¡ô¥OR³oªø¾ã¼ÆÅܼƬO¸ÓªíAÄæ³Ì«á¤@Ó¦³¤º®eÀx¦s®æ ¦C¸¹
Arr = .Range("A1:G" & R)
'¡ô¥OArr¬O¤Gºû°}¦C!¥H¸Óªí[A1]¨ìGÄæRÅܼƦC½d³òÀx¦s®æÈˤJ
For i = R To 2 Step -1
'¡ô³]°f°j°é!!i±qRÅܼƨì2,³v¦¸´î 1
T = Arr(i, 7)
'¡ô¥OT³o¦r¦êÅܼƬOi°j°é¦C7ÄæArr°}¦CÈ
If Left(T, 14) = TT Then
'¡ô¦pªGTÅܼƨú¥ª°¼14Ó¦r¤¸Èè¦n¬O TT¦r¦êÅܼÆÈ?
V = Val(Mid(T, 15, 2))
'¡ô¥OV³oµu¾ã¼ÆÅܼƬO Val()¨ç¼ÆÂà¤Æ¼Æ¦r¦^¶ÇªºÈ,
'Val(TÅܼƱq²Ä15¦r¨ú2¦r¤¸)
If V > VV Then VV = V
'¡ô¦pªGVÅܼƤj©ó ³oVVµu¾ã¼ÆÅܼÆ!´N¥OVVÅÜ¼Æ = VÅܼÆ
End If
Next i
Xrr(1) = zDay: Xrr(7) = TT & Format(VV + 1, "00")
'¡ô¥OXrr³o¤@ºû°}¦C1¯Á¤Þ¸¹°}¦CȬO zDayÅܼÆ
'¡ô¥OXrr³o¤@ºû°}¦C7¯Á¤Þ¸¹°}¦CȬO TTÅܼƳs±µ VVÅܼÆ+1«á¥H¨â½X¦^¶Çªº¦r¦ê
.Range("A" & R + 1).Resize(1, 7) = Xrr
'¡ô¥O¸ÓªíAÄæRÅܼÆ+1¦C¦ì¸mÀx¦s®æÂX®i¦V¥k7Äæ½d³òÀx¦s®æÈ ¥HXrr¤@ºû°}¦Cȱa¤J
With .Range("A1:G" & R + 1)
'¡ô¥H¤U¬OÃö©ó¸Óªí[A1]¨ì GÄæRÅܼÆ+1¦C½d³òÀx¦s®æªºµ{§Ç
.Sort Key1:=.Item(1), Order1:=xlAscending, _
Key2:=.Item(7), Order2:=xlAscending, Header:=xlYes
'¡ô¥O¸Ó½d³òÀx¦s®æ°µ±Æ§Ç²Ä¤@¼h¥HAÄ涶±Æ§Ç,²Ä¤G¼h¥HGÄæ°µ¶¶±Æ§Ç,¦³¼ÐÃD¦C
End With
End With
MsgBox "¡¯¸ê®Æ«Ø¥ß§¹¦¨! "
'¡ô¸õ¥X´£¥Üµ¡~~
If zMode = 2 Then Call ª«¥ó_ªì©lª¬ºA: zMode = 0 Else Call ²M°£¸ê®Æ: TextBox1.SetFocus
'¡ô¦pªGzModeÅܼƬO 2!´N°õ¦æ°Æµ{¦¡ Sub ª«¥ó_ªì©lª¬ºA(),¥OzModeÅܼƬO 0,
'§_«h´N°õ¦æ°Æµ{¦¡ Sub ²M°£¸ê®Æ(),¥OÁä½L´å¼Ð¸¨¦b TextBox1¿é¤Jµ¡¤W
End Sub |
|