How can I stop a user selecting an entire row or column in excel? The problem is that user selects the row to take the data they want, but they also get a bunch of hidden cells etc. that I don't want them to take.
Lock the hidden cells, unlock everything else and protect the worksheet with the sole restriction of Select locked cells (allow everything else).
Related
I'm preventing the user from formatting cells in a worksheet in a generated Excel file by executing this code:
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("sheet1");
CTSheetProtection prot = sheet.getCTWorksheet().getSheetProtection();
prot.setFormatCells(true);
Is there a way to lock formatting for individual cells in a sheet as opposed to having to lock formatting for the entire sheet?
Likewise, is there a way to apply the other protections to individual cells?
For example, filtering and sorting - if someone tried to apply these operations on a group of cells that included a cell that was locked for that operation it would be disallowed.
In the Format Cells dialog box you can toggle cells locked or hidden. When you use "Protect Sheet" From the Review tab you can choose to protect the worksheet and the contents of locked cells, and choose what you want to allow the user to do to locked/unlocked cells. Password protect the sheet and users will not be able to remove the lock without your permission.
I'm assuming most of your cells are to be unlocked, so select all cells and set to unlocked and then lock the ones you want locked.
I am unsure of the code to do this through VBA, but it should be easy enough to find.
Logically, you would want to select all cells and then set the cells.format.protection.locked to false, and then select the ranges you want locked and set those to true. You could easily record a macro to find this code.
you should check this link, I have written a custom method to lock individual or range of cells in single or multi sheet excel file.
https://stackoverflow.com/a/63299413/6835092
for single cell locking just mention same range value. i.e a1:a1. this will lock only a1 cell.
I need to make a template where the rows and columns cannot be deleted but the cells can still be edited
Select all the cells in the sheet and unlock them
Take a cell that doesn't need to be edited (there must be at least one somewhere on the sheet) and lock it.
Activate sheet protection
You're done
Good day,
Im almost completed with my data tool which i am going to send to our offices across the country. i will like to ensure that most of the information stays the same. in order to do this, i will like to lock some cells on all the pages on my sheet.
i reseached online and there were suggestions about locking the cells and then protecting the page. however, when i do that, i cant edit ALL the cells on the prpotected page. is there a way to protect only some cells so that they are untouchable and some are edittable?
thanks
You must unlock the cells that should stay editable after protecting the sheet. You can do that in the Formating Cells Dialog. First select the cells you want to format. Then press {ctrl + 1}. On the protection tab, deselect the locked option. Then protect the sheet.
How to enable sorting on locked cells (columns) in Excel 2010?
Tried many methods, including what seemed to be the correct method (i.e. protecting sheet and leaving Sort option checked) but still unable to sort.
Example:
Question Answer
======== ======
What's your name? Johnny
How old are you? 703
I want Question column locked (so user can't change the question) and Answer column not locked (so user can enter answer!). But I want to be able to sort on the Question column.
This is the best I've been able to achieve. Allows sorting but user can't select (therefore copy) any of the locked cells. If the range is converted to a table, the user will also be able to use 'Auto Filters' using this method.
Every step is required.
Unlock every cell (Right click > Format Cells > Protection >
Locked)
Lock Every column you want locked (select entire column to
lock every cell in column)
Unlock headers - select entire first row
to unlock every cell in row
(this will allow sorting but also means
the header text can be changed by the user) (not required if range has been converted to table)
Add Editable range for
the entire worksheet - Review tab > Allow Users to Edit
Ranges > Range > New > A:AZ (the range you want to be sortable)
Protect worksheet - let them do everything but select locked cells (allowing select lock cells prevents sorting from working)
I imagine you can allow other permissions when protecting worksheet but I didn't need to so haven't tried.
I want to set up Data Validation on a cell / row of cells so that the value in that particular cell cannot be changed but all the rest of the sheet can be edited, thus why I am not using read only.
Currently if I enter the value in the cell, go to Data > Data Validation > Custom & enter ""it achieves this (see screenshots http://imgur.com/a/Ggqar)
What I want to do is set this validation via the cell rather than manually as I plan on writing this field entry when create the excel document through my application.
I have done a lot on searching online and found methods for doing countif etc.. but nothing deal with formula entry for the Custom criteria.
Is anyone able to help?
Thanks for the quick reply DanB but it's not exactly what I am trying to achieve. My end goal is that my application can pass a value into the file (Column A Row 1 [If easier for formatting it can go into each row in column A which is populated but not required]) and the file will be saved locally. The user will then be entering details in Column B, C, D, E, etc... on their local machine, saving it and processing the file again. I want the application to check Row 1 Col A for the value and decide on how to process the remainder of the file based on this value (the reading the values in the file works already). Because each time my application generates a file it will be unique I want to try do the Data Validation using a formula in the cell so that I can write it using my application and not have to manually apply settings to the file. Is it possible to do this kind of validation using only formulas in the cell when populating it?
Fastest solution would be to use a Protected sheet, but only protect that Cell.
To do this, select the entire sheet, and choose Format Cells.
On the Protection tab, remove the check from Locked.
Now, select just the cell you want to protect, and lock it using the same method. At this point, your entire sheet, except for the 1 cell should have Locked unchecked.
Now, on the review tab within Excel, choose protect Sheet, and uncheck the option to "Select Locked Cells".
Then, while the sheet is protected(you can password protect that part of it), that cell can't even be selected, yet the entire rest of the sheet can be.