hello, help PLEASE!
I haven't used userforms very much before so still trying to understand what causes error messages.
Scenario:
• I have a master list of job roles which I load into ListBox1 on userform.
• There is another worksheet which contains a list of business functions or activies. Against each function, ONE OR MORE job roles are assigned from the master list (in the one cell, separated by "; " and line break).
The idea is that when I double-click one of these cells:
(1) the user form opens
(2) master list loads into ListBox1
(3) contents of active cell are unravelled ("textsplit") and loaded into ListBox2 (and also removes these from ListBox1)
(4) I can then transfer jobs between ListBox1 and ListBox2, then save back to the cell from where they came...
So far:
Much trial and error, this works perfectly when there is already some information in the active cell, that is, it loads the master list and contents of current cell into listbox 1 & 2 respectively. I can move the jobs from one box to the other, then save the changes back to the original cell. Yay!
My problem:
When the active (source) cell is BLANK:
(1) I double click and ListBox1 is populated with the full list as planned;
(2) ListBox2 is empty (consistent with empty active cell)
(3) I transfer information from ListBox1 to ListBox2 successfully
(4) I click update, then...
I get "runtime error 13 type mismatch"
The error occurs in the ActiveCell row in code below...
Private Sub btn_update_Click()
ActiveCell.Value = WorksheetFunction.TextJoin("; " & Chr(10), True, ListBox2.List)
Unload Me
End Sub
Any ideas why this works perfectly when there is already information in the active cell and throws an error when I'm running from an empty cell? The ListBox2 contents look OK before I update...
I haven't used userforms very much before so still trying to understand what causes error messages.
Scenario:
• I have a master list of job roles which I load into ListBox1 on userform.
• There is another worksheet which contains a list of business functions or activies. Against each function, ONE OR MORE job roles are assigned from the master list (in the one cell, separated by "; " and line break).
The idea is that when I double-click one of these cells:
(1) the user form opens
(2) master list loads into ListBox1
(3) contents of active cell are unravelled ("textsplit") and loaded into ListBox2 (and also removes these from ListBox1)
(4) I can then transfer jobs between ListBox1 and ListBox2, then save back to the cell from where they came...
So far:
Much trial and error, this works perfectly when there is already some information in the active cell, that is, it loads the master list and contents of current cell into listbox 1 & 2 respectively. I can move the jobs from one box to the other, then save the changes back to the original cell. Yay!
My problem:
When the active (source) cell is BLANK:
(1) I double click and ListBox1 is populated with the full list as planned;
(2) ListBox2 is empty (consistent with empty active cell)
(3) I transfer information from ListBox1 to ListBox2 successfully
(4) I click update, then...
I get "runtime error 13 type mismatch"
The error occurs in the ActiveCell row in code below...
Private Sub btn_update_Click()
ActiveCell.Value = WorksheetFunction.TextJoin("; " & Chr(10), True, ListBox2.List)
Unload Me
End Sub
Any ideas why this works perfectly when there is already information in the active cell and throws an error when I'm running from an empty cell? The ListBox2 contents look OK before I update...