ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How To Validating Range of Cells (https://www.excelbanter.com/excel-programming/436212-how-validating-range-cells.html)

aushknotes

How To Validating Range of Cells
 
Hi, without going cell-by-cell, is there any quick way to validate a range of
cells (e.g. A1:B10) to be numeric and returns the error cell address if not
numeric? Thanks.

Tim Williams[_2_]

How To Validating Range of Cells
 
What's wrong with going cell-by-cell ?

Tim

"aushknotes" wrote in message
...
Hi, without going cell-by-cell, is there any quick way to validate a range
of
cells (e.g. A1:B10) to be numeric and returns the error cell address if
not
numeric? Thanks.




Rick Rothstein

How To Validating Range of Cells
 
As long as the code will not be used in anyway as part of a User Defined
Function, the you can use code constructed like this...

Dim R As Range, TextAddress As String
.....
.....
Set R = Range("A1:H14")
On Error Resume Next
TextAddress = R.SpecialCells(xlCellTypeConstants, xlTextValues).Address
If Len(TextAddress) = 0 Then
MsgBox "All cells in range are either numbers or blanks"
Else
MsgBox "Cell " & TextAddress & " is not a number"
End If

--
Rick (MVP - Excel)


"aushknotes" wrote in message
...
Hi, without going cell-by-cell, is there any quick way to validate a range
of
cells (e.g. A1:B10) to be numeric and returns the error cell address if
not
numeric? Thanks.



aushknotes

How To Validating Range of Cells
 
Perfect & very neat! Thanks a million!



"Rick Rothstein" wrote:

As long as the code will not be used in anyway as part of a User Defined
Function, the you can use code constructed like this...

Dim R As Range, TextAddress As String
.....
.....
Set R = Range("A1:H14")
On Error Resume Next
TextAddress = R.SpecialCells(xlCellTypeConstants, xlTextValues).Address
If Len(TextAddress) = 0 Then
MsgBox "All cells in range are either numbers or blanks"
Else
MsgBox "Cell " & TextAddress & " is not a number"
End If

--
Rick (MVP - Excel)


"aushknotes" wrote in message
...
Hi, without going cell-by-cell, is there any quick way to validate a range
of
cells (e.g. A1:B10) to be numeric and returns the error cell address if
not
numeric? Thanks.


.



All times are GMT +1. The time now is 01:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com