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
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