Combobox2 (based on data validation) does not change values upon selecting value Combobox1

Coenzinho

New Member
Joined
Jan 31, 2017
Messages
1
Hello Forum,

As a newcomer to VBA i would like to request your help on resolving the following issue i have:

The first Userform ("lvl2Frm") with a combobox pops up after clicking a commandbutton. The user can select a value in the combobox with source: =OFFSET(Lists!$E$1,MATCH(AI7,Lists!$E:$E,0)-1,1,COUNTIF(Lists!$E:$E,AI7),1)
This value is entered in the spreadsheet (field AI8). When chosen, they are asked to add a subitem; a second form pops up with a combobox which "uses" value AI8 for its data validation:
=OFFSET(Lists!$I$1,MATCH(AI8,Lists!$I:$I,0)-1,1,COUNTIF(Lists!$I:$I,AI8),1)

However, the first time this works well, but after the forms are hidden, it seems to "remember" the value of combobox 1 and only showing the list based on this first selection in combobox of the first form.

Hoping to find a solution here that the second combobox uses the indeed the AI8 value over and over again. Thanks!

Here's the code i've created sofar:

In the first form (lvl2Frm):

Private Sub ComboBox2_Change()




Dim wbs2 As String
Dim rowNr As Integer


Dim iRet As Integer
Dim strPrompt As String


wbs2 = ComboBox2.Value

Range("AI8").ClearContents
Range("AI9").ClearContents
Range("AI8") = wbs2
rowNr = Range("B" & Rows.Count).End(xlUp).Row


strPrompt = "Want to add Sub activity?"

iRet = MsgBox(strPrompt, vbYesNo)

If iRet = vbNo Then
If rowNr > 17 Then newRow
Cells(rowNr + 1, 6) = wbs2


lvl2Frm.Hide

Else
lvl3Frm.Show

End If
lvl2Frm.Hide
lvl3Frm.Hide

End Sub

Then it goes to the second form (lvl3Frm):


Private Sub ComboBox3_Change()




Dim wbs3 As String
Dim rowNr As Integer


wbs3 = ComboBox3.Value
Range("AI9") = wbs3


rowNr = Range("B" & Rows.Count).End(xlUp).Row


If rowNr > 17 Then newRow
Cells(rowNr + 1, 6) = wbs3

lvl3Frm.Hide
lvl2Frm.Hide

End Sub

Many tahnks in advance,

KR,
Coen
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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