Having trouble populating 3rd combo box.

Status
Not open for further replies.

Saru

New Member
Joined
May 15, 2020
Messages
19
Office Version
  1. 365
Platform
  1. Windows
Here is the data sample:
Drop-Downs (col A)Items (col B)Parent DropDown(col C)
Main_CatHouse
Main_CatFood
Main_CatVehicle
Main_CatEntertainment
Main_CatPersonal
Main_CatMedical
Main_CatDental
Main_CatVision
CatUtilitiesHouse
CatHousehold_ItemsHouse
CatMaintenanceHouse
CatTollsVehicle
CatTaxesVehicle
CatRoad TripEntertainment
CatLocal ActivitiesEntertainment
CatKevinPersonal
CatSaruPersonal
CatPetPersonal
CatSaruMedical
CatKevinDental
CatSaruDental
CatKevinVision
CatSaruVision
Sub CategoryElectricUtilities
Sub CategoryWaterUtilities

Not sure what i am doing wrong. I cant seem to populate the 3rd combo box. Below is my code;

Option Explicit
Public enableevents As Boolean
Dim sh As Worksheet

Private Sub UserForm_Activate()
Set sh = ThisWorkbook.Sheets("DropDowns")
Dim i As Long

cboMainCat.Clear
For i = 2 To sh.Range("A" & Application.Rows.Count).End(xlUp).Row ' becoz 1 is the header
If sh.Range("A" & i).Value = "Main_Cat" Then
cboMainCat.AddItem sh.Range("B" & i)
End If
Next i
End Sub

Private Sub cboMainCat_Change()
Dim i As Long
cboCat.Clear
cboSubCat.Clear
For i = 2 To sh.Range("A" & Application.Rows.Count).End(xlUp).Row ' becoz 1 is the header
If sh.Range("A" & i).Value = "Cat" And sh.Range("C" & i).Value = cboMainCat.Value Then
cboCat.AddItem sh.Range("B" & i)
End If
Next i
End Sub

Private Sub cboCat_Change()
Dim i As Long
cboSubCat.Clear
For i = 2 To sh.Range("A" & Application.Rows.Count).End(xlUp).Row ' becoz 1 is the header
If sh.Range("A" & i).Value = "Sub Category" And sh.Range("C" & i).Value = cboCat.Value Then
cboSubCat.AddItem sh.Range("B" & i)
End If
Next i
End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Duplicate 3 Dependent Combo Box

Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread.
Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,268
Messages
6,171,100
Members
452,379
Latest member
IainTru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top