Forum Discussion
Abdullah_Shurjeel
Mar 26, 2021Copper Contributor
Data Validation Settings fails to apply
Hope someone can help me on this. I have 3 cells(A1,A2,A3) for which I want only Whole Numbers like 1,2,3 and do not want decimals like 0.1 or 0.5 and neither want alpha chars so I have set Data ...
- Mar 26, 2021
Try this:
Private Sub Worksheet_Change(ByVal Target As Range) 'Only numeric values Const CELL_ADDRESS = "A1:A3" 'change range Dim rng As Range Dim f As Boolean If Not Intersect(Target, Range(CELL_ADDRESS)) Is Nothing Then For Each rng In Intersect(Target, Range(CELL_ADDRESS)) If Not IsNumeric(rng.Value) Then f = True ElseIf Not rng.Value = Int(rng.Value) Then f = True End If If f Then MsgBox "You must enter only whole numbers!", vbCritical, "Invalid Input" Application.EnableEvents = False Application.Undo Application.EnableEvents = True Exit For End If Next rng End If End Sub
NikolinoDE
Mar 26, 2021Platinum Contributor
TRIM removes the digits after the decimal point.
Matrix formula:
= SUM (TRIM (A1: A3))
Additional Formulas:
=INT(A1)
=TRUNC(A1)
=ROUND(A1,0)
Hope I was able to help you with this info.
Nikolino
I know I don't know anything (Socrates)
Matrix formula:
= SUM (TRIM (A1: A3))
Additional Formulas:
=INT(A1)
=TRUNC(A1)
=ROUND(A1,0)
Hope I was able to help you with this info.
Nikolino
I know I don't know anything (Socrates)
Abdullah_Shurjeel
Mar 27, 2021Copper Contributor
Thanks Nikolino for the response.
The formulas are helpful for removal of decimal points.
The formulas are helpful for removal of decimal points.