How To Validating Range of Cells

  • Follow


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.
0
Reply Utf 11/16/2009 5:48:01 AM

What's wrong with going cell-by-cell ?

Tim

"aushknotes" <aushknotes@discussions.microsoft.com> wrote in message 
news:BB6EF563-4364-4D16-A8E5-E30B917EA219@microsoft.com...
> 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. 


0
Reply Tim 11/16/2009 6:56:43 AM


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" <aushknotes@discussions.microsoft.com> wrote in message 
news:BB6EF563-4364-4D16-A8E5-E30B917EA219@microsoft.com...
> 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. 

0
Reply Rick 11/16/2009 7:13:25 AM

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" <aushknotes@discussions.microsoft.com> wrote in message 
> news:BB6EF563-4364-4D16-A8E5-E30B917EA219@microsoft.com...
> > 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. 
> 
> .
> 
0
Reply Utf 11/16/2009 11:44:01 AM

3 Replies
289 Views

(page loaded in 0.051 seconds)


Reply: