What should I enter in the Data Validation drop box to allow user to only enter negitive numbers ie numbers less than zero like -1
Thks
What should I enter in the Data Validation drop box to allow user to only enter negitive numbers ie numbers less than zero like -1
Thks
Set "Allow" to either "Whole Number" or "Decimal". Then set "Data" to "Less Than". Finally set "Maximum" to 0. You can also do it via VBA, but it's usually not necessary to use VBA for this task.
[VBA]Sub Example()
Dim rng As Excel.Range
Set rng = Excel.ActiveSheet.Range("E6")
With rng.Validation
.Delete 'Clear any old validation.
.Add xlValidateWholeNumber, xlValidAlertStop, xlLess, "0"
.ErrorTitle = "Invalid Entry"
.ErrorMessage = _
"This cell only accepts values less than zero (Negative Numbers)."
End With
End Sub[/VBA]
Cordially,
Aaron
Keep Our Board Clean!
- Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
- Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.