Excel Data Validation - Dont allow Formulas - excel

Is there any way of using Data Validation to stop someone entering a Formula and only allow text?
I don't want somebody using a formula to search very hidden sheets because they will know the names of these sheets.
I know excel is not secure, but I don't want someone to easily read these sheets with just =SHEET!A1
I have tried custom validation
=ISERROR(FIND("=",A1))
but unfortunately I need to allow them to use the = sign

Yes - really simple - create a Custom data validation and use formula: =NOT(ISFORMULA(A1))
No need to over-engineer it with VBA, but of course its easily disabled

No there is not. The closest you could come would be to write a UDF that detects the presence of a formula; enter that UDF on some cell in the active sheet, and reference that cell in the data validation formula.
However, that would not prevent a user from entering a formula in some other cell, and then copy/paste to the validated cell. Data validation only checks when a formula is entered directly. It does not check that pasted data conforms to the rule(s).
Jeeped's suggestion of using worksheet event code would be the way to go. And you could easily protect the entire sheet from that phenomenon.

Related

Excel Add in - Refresh only my custom functions in a specific sheet

I want to update custom formulas added my Excel add in. Using Application/worksheet.Caclulate() updates whole sheet, but I want to update only those cells which are using my formulas.
I haven't tried this, but what if you used the technique described in Get formulas from a range of cells on the entire UsedRange of a worksheet. Then iterate through the returned array to find all the cells that have formulas matching one of yours. Then for each of those cells, call Calculate().
The Application object provides a method to force an immediate recalculation. Application.calculate(calculationType) starts a manual recalculation based on the specified calculationType. The following values can be specified.
full: Recalculate all formulas in all open workbooks, regardless of whether they have changed since the last recalculation.
fullRebuild: Check dependent formulas, and then recalculate all formulas in all open workbooks, regardless of whether they have changed since the last recalculation.
recalculate: Recalculate formulas that have changed (or been programmatically marked for recalculation) since the last calculation, and formulas dependent on them, in all active workbooks.
So, you could play with an argument to get the required piece recalculated.

Prevent Blank Cells with Data Validation

I'm having a seriously hard time with the simplest of Excel data validations: how do you prevent a blank value? The user needs to enter a number into a cell. If the cell has no value, Excel should throw up an error message. I've tried the following:
=COUNTIF($A5:$A27, "")=0
=ISBLANK($A5)
=ISBLANK($A5)=FALSE
and a whole assortment of ridiculous Excel gymnastics, but nothing has worked. The Ignore Blank checkbox is off, too. How hard can this be?
This is in Excel 2016 running on Windows 10. I've tried Google searches ad nauseum with different search keywords. I've tried winging it. I've tried searching on here fora simple formula to solve the problem.
Assuming you also don't want to allow a value of 0 to be entered, you can use the following validation. However, validation only applies when you're entering values into a cell. If you're in edit mode, you won't be able to hit Enter while the cell is blank. But there's nothing to stop you from ignoring the cell entirely or even selecting the cell and clearing it's contents using the Delete key.
There's no way for Excel to force fields to be mandatory and with good reason. If Excel wasn't going to let you do anything while a mandatory cell was empty, you would be stuck if there were two mandatory cells because you could never complete one cell without Excel complaining about the other cell.
You can only force cells to be mandatory when you're also running macros which could display error messages instead of performing the required tasks if the mandatory fields aren't all complete.
As per the comment, the best thing to do is highlight empty mandatory cells using conditional formatting. From the Home tab, create conditional formatting based on value equal to 0 then set the background format to red (or whatever you want).

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.

Data Validation in Excel through Cell

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.

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