Can you allow input but disable paste in Excel? - excel

I have an Excel sheet protection set up with intricate conditional formats. I want to allow user input (typing) in a range of cells, but I want to disable copy/pasting in the same range.
2 reasons:
If a user copies from elsewhere and paste into this range, it destroys my conditional formatting. However, an unsophisticated user will never remember to use "paste value only".
If a user is in filtered view and copy and paste in a non-continuous range, the paste will overwrite values in hidden rows without the user even knowing, all they see is that some copied values "disappeared", thus changing values in hidden cells unintentionally.
Is this doable without VBA? because I need this to work with Excel Online with users using the file through SharePoint.

Related

Is there a way to lock individual cells (not the entire Excel worksheet) to prevent formatting?

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.

How to Paste into visible cells in a filter in Excel?

I have data in one workbook and I have filtered columns in another workbook, when I want to copy the data from one workbook and paste it to the visible cells in the filtered area, it gets pasted to the hidden cells as well.
I googled alot but nothing was useful even I tried the Kutools software but did not work.
How to paste the data into visible cells?
A workaround I like to use is to use reference in the filtered sheet. Slightly longer method, but it works. Follow the steps below
Set the reference in first cell. E.g. ='Sheet1!A1'
Click and drag to copy the formula to all cells below (or Copy, and Paste into multiple selection). DO NOT double click to fill down, as it will include hidden cells.
If needed, clear filter and copy- paste values
Let me know if this works for you.

Allow Copy/Paste and change font in an unlocked cell of a locked Excel sheet

I am creating a template in excel where I only want the user to be able to enter information in some of the cells. For that reason I have locked some cells and unlocked some others and I have also protect the corresponding sheet.
The user wants to be able to copy information from other excel sheet to one of the unlocked cells of the template and be able to change the format of the pasted text, being bold and underline options avaliable.
Is there any way to do that without having to unlock the sheet?
Thank you in advance for your time.
There are options when you apply protection to the sheet to still allow formatting.
There is no issue copying and pasting into a locked cell as far as I am aware.
There is an option when you apply protection to a worksheet in Excel to allow "Format Cells". Choose this if you want them to be able to apply formatting to the cell. Likewise, Format Rows and Format Columns if you want the user to be able top adjust the row height and column width.

Excel: Can we prevent Paste Operation on cells

I have made one worksheet. And there I don't have option for Macro Enabled, as It is going to be distributed among lots of users to fill the information.
Now the question is, there are some data validation fields in worksheet.
If I do copy any data and paste on that field column, it takes any values in that, which is not correct.
Is there any way to prevent paste on cells without Macro code?
Thank you,
If you want to prevent ANY data entry in those cells you can mark them as locked & protect the sheet with a password.
If you want to allow editing those cells but need to validate that only certain data is allowed, you can use Data Validation, Custom & enter a formula.
You won't be able to use custom VBA functions but most standard Excel functions should work.

Excel Copy and Paste while maintaining data validation

When I perform a copy and paste from a blank cell to a cell with data and validation, the validation in the destination cell itself gets deleted.
Is there anyway I could maintain the validation in the destination cell while only pasting the values? (And validating the contents that are pasted)
(Also, and hence the reason why I ask this, I'm not allowed to use the "Paste Special" feature, so a workaround is required)
You have to use VBA (create a macro) to be able to do this.
An example of some code is at this SuperUser link.

Resources