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

[µo°Ý] ²¤Æµ{¦¡

[µo°Ý] ²¤Æµ{¦¡

§Ú§Q¥ÎUserform°µ­pºâ®É»Ý­n¿ï©w­n­pºâªºÄæ¦ì
¬G³]©w¨C¤@­Ósectionªº°_©lÄæ¦ì-"Start Row"¤Î"End Row"
¥B¦bCritera¦s¦b®É¤~¥i¿é¤J°_©lÄæ¦ì,·í¥¦¬°"N/A"®É°_¨ÏÄæ¦ì«h¤£¥i¿é¤J

©ó¬O´N¼g¤F¤@ªø¦êªºcode
·Q°Ý¤j®a¦P¼Ëªº°ÝÃD·|«ç»ò¼g¥i¥H¤ñ¸û²¤Æ?
ÁÂÁÂ
'------------------------------------------
If TextBox3.Locked = True Then
    CC = 1
Else
    If TextBox5.Locked = True Then
        CC = 2
    Else
        If TextBox7.Locked = True Then
            CC = 3
        Else
            If TextBox9.Locked = True Then
                CC = 4
            Else
                If TextBox11.Locked = True Then
                    CC = 5
                End If
            End If
        End If
    End If
End If

iC = 1
Do Until iC > CC
    If iC = 1 Then
        StartRow = Val(TextBox1.Text)
        EndRow = Val(TextBox2.Text)
    End If
    If iC = 2 Then
        StartRow = Val(TextBox3.Text)
        EndRow = Val(TextBox4.Text)
    End If
    If iC = 3 Then
        StartRow = Val(TextBox5.Text)
        EndRow = Val(TextBox6.Text)
    End If
    If iC = 4 Then
        StartRow = Val(TextBox7.Text)
        EndRow = Val(TextBox8.Text)
    End If
    If iC = 5 Then
        StartRow = Val(TextBox9.Text)
        EndRow = Val(TextBox10.Text)
    End If
    If iC = 6 Then
        StartRow = Val(TextBox11.Text)
        EndRow = Val(TextBox12.Text)
    End If
¤¤¶¡­pºâµ{¦¡

iC = iC + 1
Loop
'----------------------------------

¦^´_ 1# acdx
¤W­±¨SÁ¿²M·¡
§Ú¦bSub ComboBox1_Change¸Ì¦³³]©w·íComboBox1.Value ¤£µ¥©ó"N/A"(§YC1~C5)®É TextBox¤~¥i¿é¤J§_«h·|³QLocked
Private Sub ComboBox1_Change()
If ComboBox1.Value = "N/A" Then
    TextBox1.Locked = True
    TextBox2.Locked = True
    TextBox1.BackColor = &H8000000A
    TextBox2.BackColor = &H8000000A
Else
    TextBox1.Locked = False
    TextBox2.Locked = False
    TextBox1.BackColor = &H8000000B
    TextBox2.BackColor = &H8000000B
End If
End Sub

TOP

  1.   Dim myControl(1 To 6, 1 To 3) As Control
  2.   
  3.   '³]©w±±¨î¶µ°}¦C
  4.   For i = 1 To UBound(myControl)
  5.     Set myControl(i, 1) = Controls("ComboBox" & i)
  6.     Set myControl(i, 2) = Controls("TextBox" & 2 * i - 1)
  7.     Set myControl(i, 3) = Controls("TextBox" & 2 * i)
  8.   Next
  9.   
  10.   For iC = 1 To UBound(myControl)
  11.     If myControl(iC, 2).Locked Then Exit For
  12.    
  13.     StartRow = Val(myControl(iC, 2).Value)
  14.     EndRow = Val(myControl(iC, 3).Value)
  15.    
  16.     '¤¤¶¡­pºâµ{¦¡
  17.   Next
½Æ»s¥N½X
¦^´_ 1# acdx

TOP

¦^´_ 1# acdx

¥i¥H¥Îselect case¨Ó¥N´Àif  else if
ss

TOP

¦^´_ 3# stillfish00
¤Ó·PÁ¤F ³oºØ¼gªk¬O§Ú©Ò¨S¹Á¸Õ¹Lªº
¥t¥~§Ú·Q³]©w¦¨²Ä¤@­ÓCritera¦³¿ï¾Ü®É(§YComboBox1¤£µ¥©óN/A)¤U¤@­ÓComboBox2¤~¥i¥H¿ï¾Ü
¸Ó¦p¦ó¼g©O?

TOP

¥»©«³Ì«á¥Ñ stillfish00 ©ó 2013-8-14 17:25 ½s¿è

¦^´_ 5# acdx
²³æªº°µªk´N¬O¦b§A2#ªºChange¨Æ¥ó¤¤§PÂ_´N¥i¥H¤F¡A¦]¬°§A¥u¦³6­ÓComboBoxÁÙºâ¤Ö¡A¥u­n¼g6­ÓComboBoxN_Change()´N¦n¤F¡C

­Y¬O¼Æ¤Q¡B¼Æ¦Ê­Ó±±¨î¶µ¡A¨Æ¥ó°õ¦æ°Ê§@Ãþ¦ü¡A¥i¦Ò¼{¥Îª«¥óÃþ§O¼Ò²Õ(¸û½ÆÂø)¥h©w¸q¦@³qªº¨Æ¥ó¡G
·s¼W¤@ª«¥óÃþ§O¼Ò²Õ¡A©R¦W¬°clsComboBoxMyEvents
  1. Public WithEvents myComboBox As MSForms.ComboBox
  2. Private cbForLock As MSForms.ComboBox

  3. Public Sub setObject(ByRef ctl As MSForms.ComboBox)
  4.   Set myComboBox = ctl
  5. End Sub

  6. Public Sub setLinkForLock(ByRef ctl As MSForms.ComboBox)
  7.   Set cbForLock = ctl
  8. End Sub

  9. Private Sub myComboBox_Change()
  10.   If cbForLock Is Nothing Then Exit Sub
  11.   
  12.   If myComboBox.Value = "N/A" Then
  13.     cbForLock.Enabled = False
  14.   Else
  15.     cbForLock.Enabled = True
  16.   End If
  17. End Sub
½Æ»s¥N½X
§Aªºªí³æ:
  1. Private Const COMBOBOX_COUNT = 6
  2. Dim myCombo(1 To COMBOBOX_COUNT) As clsComboBoxMyEvents

  3. Private Sub UserForm_Initialize()

  4.   '............................
  5.   
  6.   '¥[¤W¤U­±³o¬q
  7.   For i = 1 To COMBOBOX_COUNT
  8.     Set myCombo(i) = New clsComboBoxMyEvents
  9.     myCombo(i).setObject Controls("ComboBox" & i)
  10.     If i < COMBOBOX_COUNT Then myCombo(i).setLinkForLock Controls("ComboBox" & i + 1)
  11.   Next i
  12. End Sub
½Æ»s¥N½X
¤j·§Ãþ¦ü³o¼Ë¡A§Ú¤]¤£¬O«Ü±`¥Î¡C

TOP

¦^´_ 6# stillfish00
¤Ó·PÁ¤F
³o¸ÌÅý§Ú¾Ç¨ì¤Ó¦hªF¦è¤F

TOP

        ÀR«ä¦Û¦b : ±o²z­nÄǤH¡A²zª½­n®ð©M¡C
ªð¦^¦Cªí ¤W¤@¥DÃD