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

[µo°Ý] ·Q½Ð±Ðªí³æ±±¨î¶µªº´X­ÓºÃ°Ý

[µo°Ý] ·Q½Ð±Ðªí³æ±±¨î¶µªº´X­ÓºÃ°Ý

ªO¤Wªº«e½ú­Ì¦n
§Ú¦bEXCEL¸ÌªºAªí°µ¤F¤@­Ó«ö¶s©I¥sªí³æ test4.rar (35.72 KB)
ªí³æ¿ï¨ú½d³ò¬°B:H¡A¦ý«ö¶sCALL¥Xªºªí³æ½d³ò«o¸¨¦bA:H
¦pªG¤£¥Î«ö¶sª½±µ¦b§Ö³t¥\¯à°ÏÂI¿ï"ªí³æ"ªº¸Ü
¤~·|¬O§Ú­nªºB:H
µM¦ÓCÄ欰¤U©Ô¦¡¿ï³æ¡A¸Ó¦p¦ó¦bªí³æ¤¤¤]¥X²{¤U©Ô¿ï³æ?

¥t¥~¡A¦bBªí¸Ì°µ¤F4­Ó«ö¶s
¨Ì§Ç¬°¡y­ºµ§¡B¤W¤@µ§¡B¤U¤@µ§¡B¥½µ§¡z
·Q«ü©wBªíB2ªº½s¸¹
­ºµ§=A!A2¡A¤W¤@µ§=B2-1¡A¤U¤@µ§=B2+1¡A¥½µ§=A!AÄæ³Ì«á¤@µ§ªº½s¸¹
4­Ó«ö¶sªº»yªk­n¦p¦ó½s¼g©O?

ÁÂÁÂ~

¥»©«³Ì«á¥Ñ GBKEE ©ó 2015-7-18 12:48 ½s¿è

¦^´_ 1# united7878
¸Õ¸Õ¬Ý
  1. '¤u§@ªí¤W¶·¦³©w¸q½d³ò¦WºÙ [database]
  2. '¦pµL ShowDataForm,¥H§@¥Î¤¤Àx¦s®æªº©µ¦ù½d³ò§@¬°[database]
  3. '¦p¦³ ShowDataForm ·|¥H¦¹[database] §@¬°ªí³æªº½d³ò
  4. Option Explicit
  5. Sub Ex_ªí³æ()
  6.    With ActiveSheet
  7.         .Names.Add "database", .Columns("B:H")
  8.         .ShowDataForm
  9.     End With
  10. End Sub
½Æ»s¥N½X
±±¨î¶µªºµ{¦¡½X
  1. 'ThisWorkbook ¼Ò²Õªºµ{¦¡½X
  2. Option Explicit
  3. Private Sub Workbook_Open() 'Àɮ׶}±Ò®É¦Û°Ê°õ¦æªºµ{¦¡½X
  4.     ¤u§@ªí2.Ex_³]©w   '-> SHEETS("B")
  5. End Sub
½Æ»s¥N½X
  1. '¤u§@ªí2 ¼Ò²Õªºµ{¦¡½X -> SHEETS("B")
  2. Option Explicit
  3. Private Sub Worksheet_Activate()  '¦bSHEETS("B") ¬°§@¥Î¤¤ªº¤u§@ªí®É,¦Û°Ê°õ¦æ
  4.     Ex_³]©w
  5. End Sub
  6. Sub EX_­º()
  7.     With SpinButton1
  8.         .Min = 2
  9.         .Value = .Min  'µ¹­È·|²o°Ê ¤W¤Uµ§ªº²§°Ê
  10.     End With
  11. End Sub
  12. Sub EX_¥½()
  13.     With SpinButton1
  14.         .Value = .Max   'µ¹­È·|²o°Ê ¤W¤Uµ§ªº²§°Ê
  15.     End With
  16. End Sub
  17. Private Sub SpinButton1_Change() '¤W¤Uµ§ªº²§°Ê
  18.     EX
  19. End Sub
  20. Private Sub EX()
  21.     Dim Rng As Range, Ar(), i As Integer
  22.     Set Rng = Range("C3,F3, B6, D6, B8, F7, D2")  '¨î©w­û¤u¸ê®Æ¥d¤W­n¿é¤JªºÀx¦s®æ
  23.     Ar = Sheets("A").Range("B" & SpinButton1).Resize(, 7).Value  'SpinButton1¤Wªº­È¾É¤J°}¦C
  24.     Range("B2") = "'00" & SpinButton1 - 1
  25.     For i = 1 To Rng.Count
  26.         Rng.Areas(i) = Ar(1, i)   'Areas:¦]­û¤u¸ê®Æ¥d¤W­n¿é¤JªºÀx¦s®æ¬°¤£³sÄòªº½d³ò
  27.         'Areas ÄÝ©Ê ¶Ç¦^ Areas ¶°¦X¡A¦¹¶°¦X¥Nªí¦h­«½d³ò¤¤ªº©Ò¦³½d³ò¡C°ßŪ¡C
  28.     Next
  29.     Range("j2").Resize(UBound(Ar, 2)) = Application.Transpose(Ar)
  30. End Sub
  31. Sub Ex_³]©w() 'SpinButton ±±¨î¶µ
  32.     Dim Rng As Range, S As Variant
  33.     With Sheets("A")
  34.         Set Rng = .Range("b1", .Range("b2").End(xlDown)) '©m¦WÄ檺¸ê®Æ½d³ò
  35.     End With
  36.     S = Application.Match(Range("c3"), Rng, 0)           '§¹¥þ¤ñ¹ï Range("c3")ªº¦r¦ê¦b©m¦WÄæ¤Wªº¦C¸¹
  37.     With SpinButton1
  38.         .Max = Rng.Cells(Rng.Count).Row                  '³Ì«áªº¦C¸¹
  39.         .Min = 2
  40.         .Value = IIf(IsNumeric(S), S, 2)                 'Range("c3")ªº¦r¦ê,¦³¤ñ¹ï¨ìµ¹¦C¸¹,§_µ¹ 2
  41.     End With
  42. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 1# united7878


    ½Ð°Ý³oªí³æ¬O«ç»ò°µªº©O?
¦bVBAµøµ¡¬Ý¤£¨ìÃö©ó¦¹¥\¯àªº¥N½X

TOP

¦^´_ 3# starry1314


°õ¦æ®É¿ý»s¥¨¶°¬Ý¬Ý



·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 4# GBKEE


    ·PÁÂ~­ì¨Ó­n¨ì¦Û­q¥\¯à°Ï ·s¼W¡I§ä¤F¤@¾ã±ß¡@ÁÙ¥H¬°¬O±N¼Ò²ÕÁôÂÃ

TOP

¦^´_ 2# GBKEE

·PÁÂG¤j
½Ð°Ý¦pªG­n¦bªí³æ¤º¨Ï¥Î¤U©Ô¦¡¿ï³æ
¬O§_¥u¯à³]­p¦Û­qªí³æ«á¦A°µ³sµ²?
¤º«Ø¶}±Òªºdatabaseªí³æµLªk¨Ï¥Î?

ÁÂÁ«ü¾É!!

TOP

¦^´_ 6# united7878
ªí³æ¤ºªºµ{¦¡½X¥i¥H,¨Ï¥Î¤º«Øªºdatabase(ShowDataForm)ªí³æ.
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 7# GBKEE


    ½Ð±ÐG¤j
¦b¦Û­qªí³æ¤º¦p¦ó³sµ²database(ShowDataForm)¨ì¦Û©w¸qªºTxetBox©O?
ªí³æ¤ºªºButton¸Ó«ç¼Ë½s¼g»P¤u§@ªí¤ºButton¤@¼Ëªº§@¥Î?
test5.rar (45.47 KB)


ÁÂÁÂ~

TOP

¦^´_ 8# united7878
¸Õ¸Õ¬Ý
  1. Option Explicit
  2. Dim Ar(), Sh As Worksheet, Msg As Boolean
  3. Dim C_Button()
  4. Private Sub UserForm_Initialize()  'ªí³æ¥¼Åã¥Ü«eªºªí³æµ{¦¡½X¨Æ¥ó
  5.     Set Sh = Sheets("A")    'Database©Ò¦b¤u§@ªí
  6.     '****************************************************************
  7.     Ar = Array(myA, myB, myC, myD, myE, myF, myG, myH)
  8.     'Åã¥Ü¸ê®Æªº±±¨î¶µ¦¬¶°¨ì°}¦C¤¤
  9.     C_Button = Array(SpinButton1, CommandButton1, CommandButton2, B2)
  10.     '«ö¶sªº±±¨î¶µ¦¬¶°¨ì°}¦C¤¤
  11.     '*****************************************************************
  12.    
  13.     myC.AddItem "¨k"
  14.     myC.AddItem "¤k"
  15.     Msg = True                          '¸ê®ÆŪ¨ú,¼g¤J¤¤
  16.     With SpinButton1
  17.         .Min = 2                        '³Ì¤p­È=²Ä2¦C¸¹
  18.         .Max = Sh.Cells(Rows.Count, 1).End(xlUp).Row '³Ì¤j­È
  19.         If .Max = 1 Then        '¨S¦³¸ê®Æ
  20.             ±±¨î¶µ False        '±±¨î¶µ¤£¥i¨Ï¥Î
  21.         Else
  22.             ¸ê®ÆŪ¨ú .Value     '¦³¸ê®Æ:Ū¨ú¨ì±±¨î¶µ
  23.         End If
  24.     End With
  25.     Msg = False
  26. End Sub
  27. Private Sub B1_Click()  '·s¼W
  28.     Dim i As Integer
  29.     Msg = True    '¸ê®ÆŪ¨ú,¼g¤J¤¤
  30.     ±±¨î¶µ True   '±±¨î¶µ¥i¨Ï¥Î
  31.     With SpinButton1
  32.         .Max = .Max + 1 '·s¼W:¼W¥[¤@¦C,³Ì¤j­È + 1
  33.         .Value = .Max   '­È­n²¾¨ì³Ì¤j­È
  34.         Ar(0).Caption = Format(.Max - 1, "0000")    '½s¸¹
  35.         Sh.Cells(.Max, 1) = .Max - 1                '¸ê®Æ¤Wªº½s¸¹
  36.         Sh.Cells(.Max, 1).NumberFormatLocal = "0000" '½s¸¹ªº®æ¦¡
  37.     End With
  38.     For i = 1 To 7
  39.         Ar(i).Value = ""          '²M°£±±¨î¶µªº­È
  40.     Next
  41.     Msg = False
  42. End Sub
  43. Private Sub B2_Click()  '²M°£
  44.     Dim i As Integer
  45.     Msg = True
  46.     With SpinButton1
  47.         For i = 0 To 7           '²M°£±±¨î¶µªº­È
  48.             If i = 0 Then
  49.                 Ar(i).Caption = ""
  50.             Else
  51.                 Ar(i).Value = ""
  52.             End If
  53.         Next
  54.         Sh.Cells(.Value, 1).Resize(, 8).Delete xlUp  '§R°£¤u§@ªí¤W(.Value)¦C
  55.         .Max = .Max - 1        '²M°£:´î¤Ö¤@¦C,³Ì¤j­È - 1
  56.         If .Value > .Max Then .Value = .Max '·í­ì¥»­È> ³Ì¤j­È,­È=³Ì¤j­È
  57.         If .Max = 1 Then   '¨S¦³¸ê®Æ
  58.             ±±¨î¶µ False   '±±¨î¶µ¤£¥i¨Ï¥Î
  59.         Else
  60.             '­×§ï§R°£«áªº½s¸¹
  61.             With Sh.Range(Sh.Range("A" & .Value), Sh.Range("A" & .Max))
  62.                 .Cells = "=ROW()-1"         '¤u§@ªí¤W¦C¸¹-1
  63.                 .Value = .Value             '¤½¦¡Âন´Ó
  64.                 .NumberFormatLocal = "0000" '½s¸¹ªº®æ¦¡
  65.             End With
  66.             Msg = False
  67.             ¸ê®ÆŪ¨ú SpinButton1
  68.         End If
  69.     End With
  70. End Sub
  71. Private Sub CommandButton1_Click() '³Ì«á¤@µ§
  72.     With SpinButton1
  73.         .Value = .Max
  74.     End With
  75. End Sub
  76. Private Sub CommandButton2_Click() '²Ä¤@µ§
  77.     With SpinButton1
  78.         .Value = .Min
  79.     End With
  80. End Sub
  81. Private Sub myB_Change()
  82.     If Msg = False Then ¸ê®Æ¼g¤J SpinButton1
  83. End Sub
  84. Private Sub myC_Change()
  85.     If Msg = False Then ¸ê®Æ¼g¤J SpinButton1
  86. End Sub
  87. Private Sub myD_Change()
  88.     If Msg = False Then ¸ê®Æ¼g¤J SpinButton1
  89. End Sub
  90. Private Sub myE_Change()
  91.     If Msg = False Then ¸ê®Æ¼g¤J SpinButton1
  92. End Sub
  93. Private Sub myF_Change()
  94.     If Msg = False Then ¸ê®Æ¼g¤J SpinButton1
  95. End Sub
  96. Private Sub myG_Change()
  97.     If Msg = False Then ¸ê®Æ¼g¤J SpinButton1
  98. End Sub
  99. Private Sub myH_Change()
  100.     If Msg = False Then ¸ê®Æ¼g¤J SpinButton1
  101. End Sub
  102. Private Sub SpinButton1_Change()   '«öÁ䦳²¾°Ê
  103.         If Msg = False Then ¸ê®ÆŪ¨ú SpinButton1
  104. End Sub
  105. Private Sub SpinButton1_SpinDown()   '«öÁä¦V¤U²¾°Ê
  106.      With SpinButton1
  107.         If .Value = .Min Then MsgBox "¤w¬O²Ä¤@µ§¸ê®Æ"
  108.      End With
  109. End Sub
  110. Private Sub SpinButton1_SpinUp()     '«öÁä¦V¤W²¾°Ê
  111.     With SpinButton1
  112.         If .Value = .Max Then MsgBox "¤w¬O²Ä³Ì«á¤@µ§¸ê®Æ"
  113.      End With
  114. End Sub
  115. Private Sub ±±¨î¶µ(B As Boolean)
  116.     Dim E As Variant
  117.     For Each E In C_Button
  118.         E.Enabled = B
  119.     Next
  120. End Sub
  121. Private Sub ¸ê®ÆŪ¨ú(X As Long)
  122.     Dim i As Integer
  123.     Msg = True   '¸ê®ÆŪ¨ú¤¤
  124.     For i = 0 To 7
  125.         If i = 0 Then
  126.             Ar(i).Caption = Sh.Cells(X, 1).Text
  127.         Else
  128.             Ar(i).Value = Sh.Cells(X, i + 1)
  129.         End If
  130.     Next
  131.     Msg = False '¸ê®Æ¤£¦bŪ¨ú¤¤
  132. End Sub
  133. Private Sub ¸ê®Æ¼g¤J(X As Long)
  134.     Dim i As Integer
  135.     Msg = True   '¸ê®Æ¼g¤J¤¤
  136.     For i = 0 To 7
  137.         If i = 0 Then
  138.             With Sh.Cells(X, 1)
  139.                 .Value = SpinButton1 - 1
  140.                 .NumberFormatLocal = "0000"
  141.             End With
  142.         Else
  143.             Sh.Cells(X, i + 1) = Ar(i).Value
  144.         End If
  145.     Next
  146.     Msg = False  '¸ê®Æ¤£¦b¼g¤J¤¤
  147. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 9# GBKEE

¦A¦¸·PÁÂGBKEE ¤j¡A³oªí³æ¼Ò²Õ¯uªº¤Ó¹ê¥Î¤F
¤p§Ì¦¬¤U«á¥²°@¤ßÆp¬ã¡A¨Ãµo´­¥ú¤j

½Ð±ÐG¤j¡A¹ê§@«áÁÙ¦³2­Ó¤pºÃ°Ý
´N¬Oªí³æ³]­pªº¦Û°Ê²£¥Í½s¸¹"NumberFormatLocal"¡A¼Æ¦r«e­n¥[¤å¦r¥i¦æ¶Ü?
§Ú©ñ¤F¤@­Ó"R" & ¦b"0000"«e¦n¹³µL®Ä
¸Ó¦p¦ó­×§ï?

ÁÙ¦³¡ABªí¤ºªºB2Äæ­ì¥»¥i¥H¿é¤J½s¸¹°µ§Ö¬d(¤§«e¬O¥Î¨ç¼Æ°Ñ·ÓJÄæ)

¦ý§ï¥ÎVBA¼¶¼g«á´NµLªk¨Ï¥Î°Ñ·Ó§Ö¬d
³o¦a¤è­n«ç¼Ë­×¥¿?

ÁÂÁÂ!!!!!

TOP

        ÀR«ä¦Û¦b : Ä@­n¤j¡B§Ó­n°í¡B®ð­n¬X¡B¤ß­n²Ó¡C
ªð¦^¦Cªí ¤W¤@¥DÃD