-key1 di kolom A  dengan nama range untuk combobox cboKey1 :: _lstKey1_
-key2 di kolom C dan D dengan nama range untuk combobox cboKey2 :: _lstKey2_
-key3 di kolom F sampai H dengan nama range untuk combobox cboKey3 :: _lst
Key3_

'untuk sheet2 saja
Private Sub cboKey1_Change()
    Dim rngKey As Range
    Dim lKey As Long

    cboKey2.RowSource = vbNullString
    cboKey2.Text = vbNullString

    If cboKey1.ListIndex > -1 Then
        'blok berikut ini bisa dibuat recursive,
        'sehingga bisa digunakan untuk multi level combo
        'lihat pola pada cbokey2 event change dalam membuat prosedur
recursive-nya
        Set rngKey = Sheet2.Range("c1").CurrentRegion.Resize(, 1)
        lKey = Application.WorksheetFunction.CountIf(rngKey, cboKey1.Text)
        If lKey <> 0 Then
            rngKey.Find(cboKey1.Text).Offset(0, 1).Resize(lKey).Name =
"_lstKey2_"
            cboKey2.RowSource = "_lstKey2_"
        End If
    End If
End Sub

Private Sub cboKey2_Change()
    Dim rngKey As Range
    Dim lKey As Long

    cboKey3.RowSource = vbNullString
    cboKey3.Text = vbNullString

    If cboKey2.ListIndex > -1 Then
        Set rngKey = Sheet2.Range("f1").CurrentRegion.Resize(,
1)                       'key1 area
        lKey = Application.WorksheetFunction.CountIf(rngKey,
cboKey1.Text)              'count key1 = cbo1
        If lKey <> 0 Then
            Set rngKey = rngKey.Find(cboKey1.Text).Offset(0,
1).Resize(lKey)            'key2 area
            lKey = Application.WorksheetFunction.CountIf(rngKey,
cboKey2.Text)          'count key2 = cbo2
            If lKey <> 0 Then
                rngKey.Find(cboKey2.Text).Offset(0, 1).Resize(lKey).Name =
"_lstKey3_"
                cboKey3.RowSource = "_lstKey3_"
            End If
        End If
    End If
End Sub

'init
Private Sub UserForm_Initialize()

    Dim lItem As Long



    'init sheet2
    With Sheet2
        lItem = .Range("a1").CurrentRegion.Rows.Count - 1
        If lItem > 0 Then
            .Range("a2").Resize(lItem, 1).Name = "_lstKey1_"
            cboKey1.RowSource = "_lstKey1_"
        Else
            cboKey1.RowSource = vbNullString
        End If
        cboKey1.Text = vbNullString

        .Range("c1").CurrentRegion.Sort .Range("c1"), xlAscending,
Header:=xlYes
        .Range("f1").CurrentRegion.Sort .Range("f1"), xlAscending,
.Range("g1"), order2:=xlAscending, Header:=xlYes
    End With
End Sub

Silakan.
Wassalam,
Kid.

2012/11/2 him mah <[email protected]>

> **
>
>
> kalau ngga keberatan minta tolong vba nya. di paste disini. soalnya
> saya buka dari hp biasa jad4 ngga bisa download
>
> Pada tanggal 02/11/12, Mr. Kid <[email protected]> menulis:
>
> > Jika itemnya sangat banyak, bisa menggunakan RowSource seperti file
> > terlampir.
> > Jika itemnya sedikit, methods add milik combo yang biasa digunakan.
> >
> > Wassalam,
> > Kid.
> >
> >
> > 2012/11/2 him mah <[email protected]>
> >
> >> **
>
> >>
> >>
> >> maaf belum bisa saya lampirkan contoh filenya, mungkin ilustrasi dulu
> >>
> >> misal kita punya 3 tabel
> >> tabel propinsi ada di sheet tblProp terdiri dari 1 kolom yaitu kolom A
> >> headernya Nama_propinsi
> >> tabel kabupaten ada di sheet tblKab terdiri dari 2 kolom, kolom A
> >> ("NAMA_PROPINSI"] dan kolom B ["NAMA_KAB"]
> >> tabel Kelurahan ada di sheet tblKel terdiri dari 3 kolom, kolom A
> >> ("NAMA_PROPINSI"] ,kolom B ["NAMA_KAB"] dan C ["NAMA_KEL"]
> >>
> >> terus saya buat UserForm dengan 3 ComboBox kemudian saya beri nama
> >> cboProp dengan rowsource ke tabel Propinsi
> >> cboKab dengan rowsource ke tabel kabupaten
> >> cboKel dengan rowsource ke tabel Kelurahan
> >>
> >> yang jadi kendala
> >>
> >> misal ketika kita memilih cboKab maka data yang ditampilkan sesuai
> >> dengan cboProp yang dipilih
> >>
> >> terus ketika kita memilih cboKel maka data yang ditampilkan adalah
> >> sesuai dengan cboProp dan cboKab yang dipilih
> >>
> >> Pada tanggal 24/07/12, [email protected]
> >> <[email protected]> menulis:
> >>
> >> > waaaahhhhh betul sekali........
> >> > terima kasih Mr Kid,ternyata ada yang simple banget ya......betapa
> >> bodohnya
> >> > diriku
> >> >
> >> > Terima Kasih,
> >> >
> >> > mardi
> >> >
> >> > From: Kid Mr.
> >> > Sent: Tuesday, July 24, 2012 3:00 AM
> >> > To: [email protected]
> >> > Subject: Re: [belajar-excel] belajar ComboBox
> >> >
> >> >
> >> > Pak Mardi,
> >> >
> >> > Coba langkah berikut :
> >> > 1. Buat nama range data NIK dan Karyawan yang ada di sheet Data (2
> >> > kolom)
> >> >>> ke sheet data
> >> >>> blok data (tanpa header, mulai baris 2, sebanyak 2 kolom dan seluruh
> >> >>> record data)
> >> >>> klik kanan pilih name a range
> >> >>> tulis di Name :
> >> > listCboNik
> >> >>> tekan OK
> >> >
> >> > 2. Atur properties combobox :
> >> >>> ke VBE, tekan F4 berulang kali, hingga tampak ada window properties
> >> yang
> >> >>> muncul
> >> >>> klik combobox
> >> >>> atur nilai-nilai properties yang ada seperti nilai properties pada
> >> gambar
> >> >>> berikut ini :
> >> > (pilih, akan cara set properties 1 atau cara set properties 2 berikut
> >> ini)
> >> > [cara set properties 1]
> >> > [cara set properties 2]
> >> >
> >> >
> >> > 3. Script mengisi nilai TextBox berdasar pilihan user di ComboBox
> >> >>> di VBE, double click ComboBox
> >> >>> akan muncul blok prosedur event untuk object combobox pada event
> >> >>> change
> >> >>> (pilihan user di combobox berganti)
> >> >>> ubah blok tersebut hingga tampak seperti berikut ini :
> >> > Private Sub ComboBox1_Change()
> >> > If ComboBox1.ListIndex <> -1 Then
> >> > TextBox1.Text = ComboBox1.List(ComboBox1.ListIndex, 1)
> >> > Else
> >> > TextBox1.Text = vbNullString
> >> > End If
> >> > End Sub
> >> >>> mungkin script tersebut tidak diperlukan jika menggunakan cara set
> >> >>> proeprties 2 di combobox-nya
> >> >
> >> > Wassalam,
> >> > Kid.
> >> >
> >> >
> >> >
> >> > 2012/7/23 <[email protected]>
> >> >
> >> >
> >> > Dear master Belajar-Excel,
> >> > bagaimana source code ringkas untuk menulis di combobox dan otomatis
> >> > tampilkan di textbox . File terlampir
> >> > Terima kasih sebelumnya.
> >> > salam,
> >> >
> >> > mardi
> >> >
> >> >
> >> >
> >> >
> >> >
> >>
> >>
> >>
> >
>
>  
>

Kirim email ke