Prevent manual input to cell but allow input from Listbox

AdrianNeal

New Member
Joined
Mar 22, 2019
Messages
5
Hi
i have sheet that allows the user to input data into a cell from selecting it from a Listbox on Userform. The values in the Listbox are from a named Range.
But the user can still manually write directly into the cell and can therefore input any value, even if its not in the named range, and I don’t want them to be able to do that.
is there a away ?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
You could use data validation on the cell using the same named range
 
Upvote 0
You must protect the sheet. Lock the cell.
Then in the code to pass the listbox data to the sheet, you must unprotect the sheet, put the data and re-protect the sheet.

eg.

Code:
    ActiveSheet.Unprotect
    Range("D10").Value = ListBox1.Value
    ActiveSheet.Protect
 
Upvote 0
thanks guys,
came to a similar conclusion last night, But I decided to block the user from manual data entry with

ActiveSheet.Protect UserInterfaceOnly:=True
 
Upvote 0

Forum statistics

Threads
1,214,374
Messages
6,119,155
Members
448,870
Latest member
max_pedreira

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