Listbox to insert data to selected line

vhdhfox

New Member
Joined
Aug 6, 2020
Messages
36
Office Version
  1. 2013
Platform
  1. Windows
Hi

currently I have a userform with a listbox that displays the data I've selected in textboxes but whatever code I try to insert the new data to either the listbox or cells of the highlighted line in the list box I get error "70" listbox does not have permission.

1597138917425.png
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
How is your listbox populated? Using RowSource? If so, you'll need to add the data to the source worksheet and then update the rowsource property to include the new row.
 
Upvote 0
Yeah the list box is populated using the RowSource but can change if needed as im wanting to use this userform to update the values of the selected row.
At the moment I have 1 Userform for inserting the data to the source worksheet and then this userform which will display all data in that work sheet which can then be updated from this second userform
 
Upvote 0
You can still use Rowsource, you just need to update the sheet, not the listbox, as I mentioned. Personally, I don't like to directly link controls to worksheets unless necessary, but it looks like you are using column headers, which does require the use of rowsource.
 
Upvote 0
By updating the worksheet do you meaning updating it by using the data entered into the textboxes and then having the listbox refresh to update the new values?
 
Upvote 0
Yes. The refresh should happen automatically.
 
Upvote 0
would it be possible to update the cells of the row that's selected in the listbox?
 
Upvote 0
Yes, you can update any cells you like. Just be aware that changing cells that are part of the Rowsource will most likely clear the selection in the listbox, so you should store the current listindex and reset it again.
 
Upvote 0
Instead of using the rowsource how would I go about populating the list box and then also what code would I use to update the cells from the userform?
 
Upvote 0
If you don't use Rowsource, you won't be able to use column headers which look to be fairly important given the number of columns in your listbox.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,213
Members
452,618
Latest member
Tam84

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