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
 

vhdhfox

New Member
Joined
Aug 6, 2020
Messages
36
Office Version
  1. 2013
Platform
  1. Windows
Okay so I've been playing around with other ideas instead of using rowsource and decided to go with the below code which works fairly well for what I want as I have lined the columns up with the textboxes above the listbox

VBA Code:
Sub UserForm_Initialize()

    Dim rngMultiColumn As Range
Set rngMultiColumn = ThisWorkbook.Worksheets("Allocate").Range("A2:O13")
With AllocateFitler.AllocateBox1
.ColumnWidths = "40;40;60;95;30;30;30;90;60;70;75;85;30"
.List = rngMultiColumn.Cells.Value
End With

End Sub

im just having trouble with inserting these lines once the data has been updated I.E. when someone selects a line in the listbox they can then update that data or add values in textbox 1,2,5.

im not sure if its possible but I would like to be able to have a command button that either deletes or replaces the data on the worksheet the data is stored based on what row in the listbox is selected.

Thanks for your help and apologies for the late reply Rory
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
37,809
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Since your data starts in row 2 and the listbox's ListIndex property starts at 0, all you need to do to get the correct row number for the cells is add 2 to the Listindex.
 

Forum statistics

Threads
1,148,140
Messages
5,745,036
Members
423,917
Latest member
Frank1931

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
Top