ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   verifying data type (https://www.excelbanter.com/excel-programming/318585-verifying-data-type.html)

benb

verifying data type
 
I want my code to look at the contents of a cell, and if the contents are not
a number (any string) execute one set of code. If the contents are a number,
skip over that code and continue on. I'm sure this can be easily done with
an If Then statement, but I don't know how to test the data type of the
contents of the cell. Could the .Type property be used? Any method for
solving this would be appreciated.

Chip Pearson

verifying data type
 
Try something like

If IsNumeric(Range("A1").Value) = True Then
' A1 is numeric
Else
' A1 is not numeric
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"benb" wrote in message
...
I want my code to look at the contents of a cell, and if the
contents are not
a number (any string) execute one set of code. If the contents
are a number,
skip over that code and continue on. I'm sure this can be
easily done with
an If Then statement, but I don't know how to test the data
type of the
contents of the cell. Could the .Type property be used? Any
method for
solving this would be appreciated.





All times are GMT +1. The time now is 12:15 AM.

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