ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] VBA ªí³æ¥\¯àµo°Ý

[µo°Ý] VBA ªí³æ¥\¯àµo°Ý

¦U¦ì«e½ú, ¤p§Ì·Q«Ø¥ß¤@­Óªí³æ¦¡¥\¯àªºµ{¦¡³]­p
¤º§t¥\¯à¦³   «Ø¥ß¸ê®Æ/½s¿è¸ê®Æ/¬d¸ß¸ê®Æ µ¥¥\¯àÀ³¥Î

«Ø¥ß¸ê®Æ
1. ¾÷¥x¸¹½XÄæ¦ì¥u¯à¿é¤J ¨â­Ó¼Æ¦r
2. »sµ{Ãþ§O¥u¯àÂI¿ï¤@­Ó
3. «p«×¥u¯à¿é¤J ¤T­Ó¼Æ¦r
4. ¦^·Å¤é´Á ¥|­Ó¼Æ¦r MMDD
5. ID «h¬O 4­Ó¤å¦r©Î¼Æ¦r³£¥i¥H
6. «ö¤U«Ø¥ß±ø½X«á¸ê®Æ·|¶]¨ìExcel Database ¹ïÀ³ªºÄæ¦ì
    AÄæ¦ì=Now()
7. «ö¤U«Ø¥ß±ø½X«á·|²£¥Í¤@­Ó§Ç¸¹¦bDatabase GÄæ¦ì
³W«h¦p¤U­±¹Ï¤ù, ¥Í²£¤é= Now ªºMMDD, ¤§«á¨Ì§Ç¦X¨Ö°_¨Ó¦¨¬°¤@²Õ§Ç¸¹, «á¨â½X¬y¤ô¸¹¬OÁקK·í¤Ñ·|¦³­«½Æ±ø¥ó


½s¿è¸ê®Æ
1.¿é¤J§Ç¸¹¦C·|±a¥X¸Óµ§¸ê®Æªº¸ê°T
2.¤å¦r¤è¶ô¥¼¿é¤J§Ç¸¹µLªk¿é¤J¸ê®Æ, §Ç¸¹¦³¿é¤J«á¤~¥i¥H½s¿è¸ê®Æ
3.½s¿è§¹¦¨´N§ó·sExcel Database¸ê®Æ



¬d¸ß¸ê®Æ
1.¬d¸ß¸ê®Æ¥u¯à¬d¸ß¤£¯à­×§ï¸ê®Æ
2.¿é¤J§Ç¸¹½X´N¥i¥H±a¥X¸ê°T


¬d¸ß¹L´Á
1. Excel EÄæ¦ì +90Days ¶W¹L·|Åã¥Ü¥X¨Ó²M³æ¤º


¨ú¥X¸ê®Æ
1.¿é¤J±ø½X§Ç¸¹·|Åã¥Ü¸Ó§Ç¸¹ªº¤U¦C¸ê°T
2.¿é¤JMH ID , ·|§â¸Ó§Ç¸¹±qDatabaseÂà´«¨ì MH Databaseªº¸ê®Æªí ,MH Database" IÄæ¦ì" Now()


¦C¦L±ø½X
1.¬O§_¯à±N²£¥Í¥X¨Óªº±ø½X§Ç¸¹Âà´«¦¨±ø½X¤å¦r®æ¦¡
2.¦C¦Lªø«× 6CM ¼e«× 1CM

±ø½X¦C¦L.rar (32.02 KB)

¦^´_ 1# v03586


    ¥Ø«e¥u¦³°µ«Ø¥ß¸ê®Æ

±ø½X¦C¦L v1.zip (41.98 KB)

TOP

¦^´_ 2# singo1232001


    ·PÁ¤j¤jªºÀ°¦£...¤p§Ì§Ú¦Û¤v¤]§V¤O¦b¬Ý¬Ý¨ä¥L¦³­þ¨Ç¥\¯à¬O¦Û¤v¥i¥H·s¼Wªº!! ¥Ø«eÁÙ¥dÃö¤¤

TOP

¥»©«³Ì«á¥Ñ ­ã´£³¡ªL ©ó 2023-1-8 14:52 ½s¿è

¥Îªí³æ¤Óªá®É¶¡¤F~~¥u°µ"·s¼W"¤Î"¬d¸ß"
¬d¸ß...¿é¤J«e6½X¼Æ¦r...¦Û°Ê¦C¥X¬Û²Å¦Xªº²M³æ¨Ñ¿ï¾Ü
¨ä¥¦ªº¥i¥Î¥Ø«eªºµ{¦¡½X¥h«÷¬Ý¬Ý~~
Xl0000359-01.rar (57.78 KB)

WG0 ... ¥kÃä¤@¦r¬O "0" ÁÙ¬O "O" ?
"¦^·Å¤é´Á" »P «Ø¥ß¤é´Á¦³¦óÃö«Y???
"¦^·Å¤é´Á" ­Y¥u¦³ "mmdd" ,¨S¦~¥÷..¦p¦ó§PÂ_¹L´Á???

TOP

¦^´_ 4# ­ã´£³¡ªL


    ©êºpª©¤j..¨S±Ô­z²M·¡, ·PÁª©¤jªº¨ó§U
     1.¥kÃä¤@¦r¬O "0"  ³o³¡¤À§Ú­×§ï¹L¤F
     2."¦^·Å¤é´Á" »P «Ø¥ß¤é´Á¦³¦óÃö«Y???   ¦^·Å¤é´Á¥Î³~¦b«Ø¥ß²£«~±q§N­á®w®³¥X«á3­Ó¤ë¤º¦³®Ä´Á­­,
                                                                                ©Ò¥HA ²£«~¥i¯à¦b1/8²Ä¤@¦¸¦^·Å,
                                                                                B²£«~¦b2/28¨Ï¥Î¬Û¦P§N­á«~(´Á­­©|¥¼¹L)  ,
                                                                                C ²£«~¦b4/10­n¨Ï¥Î®É´N¤£¯à¥Î, ¤w¶W¹L¤T­Ó¤ë¦³®Ä´Á­­

     3."¦^·Å¤é´Á" ­Y¥u¦³ "mmdd" ,¨S¦~¥÷..¦p¦ó§PÂ_¹L´Á??? ·íªì¦Ò¶q¤£©P...¦]¬°±ø½X²£¥Í¦r¦ê¤Óªø, ±ø½X¾÷µLªk±½...³oÂI¦³´¿·Q¹L...¦ý¤£ª¾¹D±qµ{¦¡¥i¤£¥i¥H¿z¿ï, ©Ò¥H¤~¯dMMDD

TOP

¦^´_ 5# v03586


3."¦^·Å¤é´Á" ­Y¥u¦³ "mmdd" ,¨S¦~¥÷..¦p¦ó§PÂ_¹L´Á??? ·íªì¦Ò¶q¤£©P...¦]¬°±ø½X²£¥Í¦r¦ê¤Óªø, ±ø½X¾÷µLªk±½...³oÂI¦³´¿·Q¹L...¦ý¤£ª¾¹D±qµ{¦¡¥i¤£¥i¥H¿z¿ï, ©Ò¥H¤~¯dMMDD

__«Øij:¦^·Å¤é´Á¨ºÄæ¨Ï¥Î¼Ð·Ç¤é´ÁYYYY/MM/DD,¿é¤J¤]¬O¼Ð·Ç¤é´Á, ¦ý±ø½X¥u¨úMMDD,
³o¼Ë´N¤ñ¸û§¹¾ã, ¥i§PÂ_¹L´Á¤]¥i§PÂ_¤é´Á¬O§_¿ù»~, ¨Ò¦p:
1) ¦^·Å¤é´Á¤p¤_«Ø¥ß¤é´Á(¬Æ¦Ü§PÂ_¤Ñ¼Æ¬O§_¥¿½T, ¦p:¦Ü¤Ö­n®t30¤Ñ)
2) ¤]¥i§PÂ_¿é¤J 02/29 ®É, ¬O§_·í¦~«×¤£¬O¶|¦~ªº¿ù»~, ¤Î¤j¤p¤ëªº¤ë©³¤é´Á, ¦p¿é¤J:0431,0631,0931,1131

¥t¥~, «Ø¥ß¤é´Á¬°¦ó»Ý­n¥[®É¶¡???

TOP

¦^´_ 6# ­ã´£³¡ªL


    «Ø¥ß¤é´Á¬°¦ó»Ý­n¥[®É¶¡
     ¦]¬°¤u¼t24¤p®É¹B§@»Ý­nª¾¹D­þ¤@­Ó®É¶¡ÂI¥Í²£ªº¸ê®Æ
     1. ·PÁª©¤jªº«Øij, ·í®É½T¹ê«Ü­W´o³o­Ó°ÝÃD, ¦]¬°YYYY/MM/DD ¨S¦³·Q¨ì³o­Ó¦h , ª©¤j¤SÀ°§Ú·Q¨ì2¤ë¦³¼í¤ëªº°ÝÃD
     2. ¦^·Å¤é´Á¤p©ó«Ø¥ß¤é´Á(¬Æ¦Ü§PÂ_¤Ñ¼Æ¬O§_¥¿½T, ¦p:¦Ü¤Ö­n®t30¤Ñ) , ¥Ø«e¥Í²£¹Lµ{¤¤¦³¤@¨Ç¨Ò¥~, ©Ò¥H¼È®É¤£±N³o­Ó§PÂ_¦b¤º, °£«D¦³¹L´Á§÷®Æ, ¤]´N¬O¦^·Å¤é+90¤Ñ
     3.¤µ¤Ñ¹Á¸Õ±Nª©¤jªºµ{¦¡¦A®M¤J¡y½s¿è¸ê®Æ¡z¡y¨ú¥X¸ê®Æ¡z¥\¯àªí¤¤, ¨ä¤¤¡y½s¿è¸ê®Æ¡z¤£ª¾¹D¦p¦ó§âOptionButton¥s¥X¨Ó, µM«á«ö¤U½s¿è§¹¦¨«á, §ó·s¸Óµ§¸ê®Æ


     4.¡y¨ú¥X¸ê®Æ¡z¥\¯àªí¤¤ , ·s¼W¨ú¥X«e¥ý¿é¤J­n¨ú¥Xªº«p«×, ¦A³z¹L±ø½X¥h§PÂ_, ¨ú¥X¨Óªº«p«×¬O§_¥¿½T, ¾á¤ß®³¿ù±ø½X«p«×, ¦b¦¨¬O¼¶¼g¤¤, ¬d¸ß¨ì±ø½X, ¤£ª¾¹D«ç»ò§â¸ê®Æ±qDatabase¸ê®Æ­¶, ·h¨ìMH Database¸ê®Æ­¶
     
  ªþ¥ó¬O§Q¥Îª©¤jªºµ{¦¡¦b©µ¦ù
Xl0000359-01.rar (54.18 KB)

TOP

§â ·s¼W/¬d¸ß/½s¿è ¨Ö¦¨¤@­Óªí³æ:
Xl0000359-02.rar (103.84 KB)

¬°¤FÀË´ú¸ê®Æªº¥¿½T©Ê, ¥N½X«D±`½ÆÂø, ¨ä¥L¥\¯àÁÙ¬O¦Û¦æ¥h¸Õ¸Õ//

TOP

¥»©«³Ì«á¥Ñ Andy2483 ©ó 2023-1-17 10:23 ½s¿è

¦^´_ 1# v03586


    ÁÂÁ«e½úµoªí¦¹¥DÃD»P½d¨Ò
ÁÂÁ ­ã´£³¡ªL«e½ú«ü¾É
«á¾Ç¤À¬q¾Ç²ß8#½d¨Ò¤ß±o¦p¤U,½Ð«e½ú°Ñ¦Ò

Option Explicit
Dim Xrr(1 To 7), Yrr(1 To 7), Zrr(1 To 7), zD As Object
Dim zT$, zK$, zType$, TS$, Un%, z%, ZZ%, zMode%, zDay
Const W1 = 257, W2 = 423
'¡ô«Å§i¦Û­qªí³æ¼Ò²Õ¸Ì¦@¥ÎÅܼÆ:(Xrr,Yrr,Zrr)¬O¤@ºû°}¦C,zD¬Oª«¥ó
'(zT,zK,zType,TS)¬O¦r¦êÅܼÆ,(Un,z,ZZ,zMode)¬Oµu¾ã¼ÆÅܼÆ,zDay¬O³q¥Î«¬ÅܼÆ
'W1¬O©T©wÅܼÆ257, W2¬O©T©wÅܼÆ423


Private Sub Cmd_1_Click() '·s¼W«ö¶s
'¡ô«ö¤F [·s¼W]«ö¶s«á·|°õ¦æ¤U¦Cµ{§Ç
Cmd_1.Enabled = False: Cmd_2.Enabled = False: Cmd_3.Enabled = False
'¡ô¥O³o3­Ó«ö¶s¥¢®Ä
Cmd_A1.Enabled = True: Cmd_A2.Enabled = True
'¡ô¥O³o2­Ó«ö¶s·|¦³®Ä
Erase Xrr, Yrr, Zrr
'¡ô²MªÅ3­Ó¤@ºû°}¦C¦@¥ÎÅܼÆ
Call ª«¥ó_UnLocked: zMode = 1
'¡ô°õ¦æ ª«¥ó_UnLocked°Æµ{¦¡ :¥OzMode³oµu¾ã¼Æ¬O1
End Sub

Private Sub Cmd_2_Click() '¬d¸ß«ö¶s
'¡ô«ö¤F [¬d¸ß]«ö¶s«á·|°õ¦æ¤U¦Cµ{§Ç
Frame1.Visible = True: TextBox5.SetFocus
'¡ô¥OFrame1³oªí³æÅã¥Ü :¥O´å¼Ð¸¨¦b TextBox5¿é¤Jµ¡¤W
Cmd_1.Enabled = False: Cmd_2.Enabled = False: Cmd_3.Enabled = False
'¡ô¥O³o3­Ó«ö¶s¥¢®Ä
Lab_A1.Visible = True: Lab_Date.Visible = True
'¡ô¥O³o¨â­Ó¼ÐÅÒÅã¥Ü
Erase Xrr, Yrr, Zrr: Set zD = Nothing
'¡ô¥O³o¨Ç®e¾¹²MªÅ
«Ø¥ß¸ê®Æ.Width = W2: Call ¨ú±o±ø½X²M³æ: zMode = 3
'¡ô¥O«Ø¥ß¸ê®Æ³oªí³æªº¼eÅܬ° W2ÅܼƼe423
End Sub

Private Sub Cmd_3_Click()
If zMode <> 3 Then Exit Sub
'¡ô¦pªGzMode³o¼Ò²Õ¦@¥ÎµuÅܼƤ£¬O 3!´Nµ²§ôµ{§Ç
«Ø¥ß¸ê®Æ.Width = W1: Frame1.Visible = False: Cmd_3.Enabled = False
'¡ô¥O«Ø¥ß¸ê®Æ³oªí³æªº¼eÅܬ° W1ÅܼƼe257
Cmd_A1.Enabled = True: Cmd_A2.Enabled = True: TextBox1.SetFocus
'¡ô¥O2­Ó«ö¶s¥¢®Ä :¥O´å¼Ð¸¨¦b TextBox1¿é¤Jµ¡¤W
Call ª«¥ó_UnLocked: zMode = 2
'¡ô°õ¦æ ª«¥ó_UnLocked°Æµ{¦¡ :¥OzMode³oµu¾ã¼Æ¬O2
End Sub

Sub ª«¥ó_UnLocked()
Dim LK, CL
'¡ô«Å§iLK,CL¬O³q¥Î«¬ÅܼÆ
LK = False: CL = &HFFFFFF
'¡ô¥OLK³o³q¥Î«¬ÅܼƬO¥¬ªL­È False,¥OCL³o³q¥Î«¬ÅܼƬO«G¥Õ¦âªº¥N½X
TextBox1.Locked = LK: TextBox2.Locked = LK: TextBox3.Locked = LK: TextBox4.Locked = LK
'¡ô¥O³o4­Ó¿é¤Jµ¡Âê©w¥¢®Ä(¥i½s¿è)
TextBox1.BackColor = CL: TextBox2.BackColor = CL: TextBox3.BackColor = CL: TextBox4.BackColor = CL
'¡ô¥O³o4­Ó¿é¤Jµ¡©³¦â¬OCLÅܼÆ(«G¥Õ¦â)
OptionButton1.Locked = LK: OptionButton2.Locked = LK: OptionButton3.Locked = LK
'¡ô¥O³o3­Ó¿ï¾Ü¶sÂê©w¥¢®Ä(¥i½s¿è)
End Sub
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

¦^´_ 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
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

        ÀR«ä¦Û¦b : ®É®É¦n¤ß´N¬O®É®É¦n¤é¡C
ªð¦^¦Cªí ¤W¤@¥DÃD