Debug Vlookup

  1. 4 tahun lalu

    gan mau nanya kenapa code saya ini error saat saya delete box PartID atau Part Type, (pengen saya kalau semua box udah diisi lalu, saya ganti Type Part otomatis semua akan hilang tapi jangan sampai debug) mohon solusinya gan. Thanks

    Code
    Private Sub UserForm_Initialize()
    Dim rng As Range
    Dim ws As Worksheet
    Set ws = Worksheets("Master All")
    Me.cboType.Clear
    For Each rng In ws.Range("masterallpart")
    Me.cboType.AddItem rng.Value
    Next rng
    Me.txtDate.Value = Format(Date, "Medium Date")
    Me.txtQtyOK.Value = ""
    Me.txtQtyNG.Value = ""
    Me.cboType.SetFocus
    End Sub
    Private Sub cboType_Change()
    'Populate dependent combo box with appropriate list items
    'according to selection in cboCategoryList.
    Dim rng As Range
    Dim ws As Worksheet
    Dim str As String
    Set ws = Worksheets("Master All")
    str = Application.VLookup(Me.cboType.Text, Worksheets("Master All").Range("mb"), 2, False)
    Me.cboPart.Clear
    On Error Resume Next
    If cboType = "" Then
    For Each rng In ws.Range("")
    Me.cboPart.AddItem rng.Value
    Next rng
    Else
    For Each rng In ws.Range(str)
    Me.cboPart.AddItem rng.Value
    Next rng
    End If
    End Sub

    Private Sub cboPart_Change()
    'Populate dependent combo box with appropriate list items
    'according to selection in cboDependentList.
    Dim rng As Range
    Dim ws As Worksheet
    Dim str As String
    Set ws = Worksheets("Master All")
    str = Application.VLookup(Me.cboPart.Text, Worksheets("Master All").Range("partall"), 2, False)
    Me.cboProcess.Clear
    On Error Resume Next
    If cboPart = "" Then
    For Each rng In ws.Range("")
    Me.cboProcess.AddItem rng.Value
    Next rng
    Else
    For Each rng In ws.Range(str)
    Me.cboProcess.AddItem rng.Value
    Next rng
    End If
    End Sub

  2. File gambar http://prntscr.com/7efdzv

  3. Nyimak dulu, itu mau buat list bertingkat ya??
    mungkin bisa diperjelas lagi debugnya di sebelah mana, atau upload aja filenya kesini biar bisa mudah di obrak-abrik :D

 

atau Mendaftar untuk ikut berdiskusi!