Moortwig
New Member
- Joined
- Feb 24, 2022
- Messages
- 1
- Office Version
- 365
- Platform
- Windows
- MacOS
- Mobile
- Web
Hi,
Backstory:
I'm trying to make a UserForm with a listbox ("cboUtrymme_01") that picks the list based on a reference inside a cell. On top of that I'm trying to retrieve the reference based on the value inside a combobox called "cbo_ID01".
What I'm trying to do is to mirror what I'm doing in the UserForm with the corresponding cells in my Excelsheet. This means I can go back to registered posts and edit them, and the values/options inside the UserForm change in realtime, and whitout pressing save.
The issue:
The main issue here is that I'm a rookie when it comes to VBA... I've managed to get the values to mirror eachother sometimes, but I haven't managed to solve how the previous picked value in "cboUtrymme_01" is shown when I open the UserForm back up after closing it. This leads to the corresponding cell being empty unless I choose it again. I can see that the code has some logical issues, but I just don't have the knowledge to fix it.
I'd apprechiate any help I can get.
What I've done so far:
The content of cell AJxx is a cellreference to a list (1_1!D85:D94). This reference will be decided based on what I pick in another listbox that's yet to be programmed...
cboID_01 has the value one in the picture below
cboUtrymme_01 contains the list (3a, 3b, 3c...) and is picked up by the content of cell AJxx
Here's my code so far
Backstory:
I'm trying to make a UserForm with a listbox ("cboUtrymme_01") that picks the list based on a reference inside a cell. On top of that I'm trying to retrieve the reference based on the value inside a combobox called "cbo_ID01".
What I'm trying to do is to mirror what I'm doing in the UserForm with the corresponding cells in my Excelsheet. This means I can go back to registered posts and edit them, and the values/options inside the UserForm change in realtime, and whitout pressing save.
The issue:
The main issue here is that I'm a rookie when it comes to VBA... I've managed to get the values to mirror eachother sometimes, but I haven't managed to solve how the previous picked value in "cboUtrymme_01" is shown when I open the UserForm back up after closing it. This leads to the corresponding cell being empty unless I choose it again. I can see that the code has some logical issues, but I just don't have the knowledge to fix it.
I'd apprechiate any help I can get.
What I've done so far:
The content of cell AJxx is a cellreference to a list (1_1!D85:D94). This reference will be decided based on what I pick in another listbox that's yet to be programmed...
cboID_01 has the value one in the picture below
cboUtrymme_01 contains the list (3a, 3b, 3c...) and is picked up by the content of cell AJxx
Here's my code so far
VBA Code:
Private Sub cboID_01_Change()
Dim i As Long, Lastrow As Long
Lastrow = Sheets("Master_01").Range("C" & Rows.Count).End(xlUp).Row
For i = 2 To Lastrow
If Sheets("Master_01").Cells(i, "C").Value = (Me.cboID_01) Or _
Sheets("Master_01").Cells(i, "C").Value = Val(Me.cboID_01) Then
Me.cboUtrymme_01 = Sheets("Master_01").Cells(i, "D").Value
Me.cboUtrymme_01.RowSource = Sheets("Master_01").Cells(i, "AJ").Value
Sheets("Master_01").Cells(i, 3).Value = Me.cboID_01
Sheets("Master_01").Cells(i, 4).Value = Me.cboUtrymme_01
End If
Next
End Sub