Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
if char is number
How can I determine whether a char is a digit or a period by menas of VBA?
Example: If char = 0 or char = 1 ... or char = 9 or char = "." Then ... There is sure to be a shorter solution. Regards, Roman |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
if char is number
If IsNumeric(char) Then
Sharad "Roman Töngi" wrote in message ... How can I determine whether a char is a digit or a period by menas of VBA? Example: If char = 0 or char = 1 ... or char = 9 or char = "." Then ... There is sure to be a shorter solution. Regards, Roman |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
if char is number
? isnumeric(".")
False ? isnumeric("5") True so if Isnumeric(char) then msgbox "It can be treated as a number" else msgbox "it can't be treated as a number" End if -- Regards, Tom Ogilvy "Roman Töngi" wrote in message ... How can I determine whether a char is a digit or a period by menas of VBA? Example: If char = 0 or char = 1 ... or char = 9 or char = "." Then ... There is sure to be a shorter solution. Regards, Roman |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
if char is number
Actually it should be
If IsNumeric(char) Or char = "." Then in case you want to check if char is only a dot. Sharad "Roman Töngi" wrote in message ... How can I determine whether a char is a digit or a period by menas of VBA? Example: If char = 0 or char = 1 ... or char = 9 or char = "." Then ... There is sure to be a shorter solution. Regards, Roman |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
if char is number
My answer was incomplete as well. If you want to check if Char is a period
you would have to check that explicitly. However, if your use of char is actually misleading and you want to check if a string is a number char = 123.45 then Isnumeric(char) would be true. if char ="A1123" then isnumeric(char) would be false -- Regards, Tom Ogilvy "Tom Ogilvy" wrote in message ... ? isnumeric(".") False ? isnumeric("5") True so if Isnumeric(char) then msgbox "It can be treated as a number" else msgbox "it can't be treated as a number" End if -- Regards, Tom Ogilvy "Roman Töngi" wrote in message ... How can I determine whether a char is a digit or a period by menas of VBA? Example: If char = 0 or char = 1 ... or char = 9 or char = "." Then ... There is sure to be a shorter solution. Regards, Roman |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
if char is number
just what I looked for,
thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to determine char or number? | Excel Discussion (Misc queries) | |||
How do I get a line under my number that is just 1 char more? | Excel Discussion (Misc queries) | |||
FIND 1 char in cell of any 3 char =True | Excel Discussion (Misc queries) | |||
8500 cells with phone number(7 char.), wishing to add area code (10 char.) | Excel Discussion (Misc queries) | |||
LIMIT NUMBER OF CHAR IN A COMBINE CELL | Excel Discussion (Misc queries) |