Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
thephoenix12
 
Posts: n/a
Default opposite of IsNumeric


Hi,

I know that IsNumeric returns true if the selection is only numbers,
but is there a function that returns true if the selection is all text?
Using If Not IsNumeric does not work, because if something contains text
and numbers it returns true, which is what I do not want.

Thanks,

Steve


--
thephoenix12
------------------------------------------------------------------------
thephoenix12's Profile: http://www.excelforum.com/member.php...o&userid=24336
View this thread: http://www.excelforum.com/showthread...hreadid=381736

  #2   Report Post  
N Harkawat
 
Posts: n/a
Default

=istext("123xd")
returns true
=isnumber("123xd") return
false

I am not sure of isnumeric function unless its a UDF, which is why it reyrns
true for part text and part number


"thephoenix12"
wrote in message
news:thephoenix12.1r3i6w_1119557148.1824@excelforu m-nospam.com...

Hi,

I know that IsNumeric returns true if the selection is only numbers,
but is there a function that returns true if the selection is all text?
Using If Not IsNumeric does not work, because if something contains text
and numbers it returns true, which is what I do not want.

Thanks,

Steve


--
thephoenix12
------------------------------------------------------------------------
thephoenix12's Profile:
http://www.excelforum.com/member.php...o&userid=24336
View this thread: http://www.excelforum.com/showthread...hreadid=381736



  #3   Report Post  
anilsolipuram
 
Posts: n/a
Default


written a function only_text, which check whether a value is all text or
not



Sub macro()
Dim ch_text As Variant
ch_text = InputBox("enter value to test")
If only_text(ch_text) Then
MsgBox "no numeric value found/ all text values"
Else
If IsNumeric(ch_text) Then
MsgBox "numeric value"
Else
MsgBox "has numeric and text value"
End If
End If
End Sub



Function only_text(v As Variant)
Dim p_text As Integer
p_text = 1

For i = 1 To Len(v)
If IsNumeric(Mid(v, i, i + 1)) Then
p_text = 0
End If

Next
If p_text = 0 Then
only_text = False
Else
only_text = True
End If
End Function


--
anilsolipuram
------------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...o&userid=16271
View this thread: http://www.excelforum.com/showthread...hreadid=381736

  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

Something like:

Option Explicit
Function IsAllText(str As String) As Boolean
Dim iCtr As Long
IsAllText = True
For iCtr = 1 To Len(str)
If UCase(Mid(str, iCtr, 1)) Like "[A-Z]" Then
'ok
Else
IsAllText = False
Exit For
End If
Next iCtr
End Function



thephoenix12 wrote:

Hi,

I know that IsNumeric returns true if the selection is only numbers,
but is there a function that returns true if the selection is all text?
Using If Not IsNumeric does not work, because if something contains text
and numbers it returns true, which is what I do not want.

Thanks,

Steve

--
thephoenix12
------------------------------------------------------------------------
thephoenix12's Profile: http://www.excelforum.com/member.php...o&userid=24336
View this thread: http://www.excelforum.com/showthread...hreadid=381736


--

Dave Peterson
  #5   Report Post  
thephoenix12
 
Posts: n/a
Default


Anilsolipuram,

I tried what you said, except, where do I put the function that you
wrote? If I put it after the sub, then an error message appears.


--
thephoenix12
------------------------------------------------------------------------
thephoenix12's Profile: http://www.excelforum.com/member.php...o&userid=24336
View this thread: http://www.excelforum.com/showthread...hreadid=381736



  #6   Report Post  
thephoenix12
 
Posts: n/a
Default


Never mind I got it...so whenever I create a function, do I have to
create it in each new module I write, or can I use it throughout the
whole workbook and have it defined in just one of my modules?


--
thephoenix12
------------------------------------------------------------------------
thephoenix12's Profile: http://www.excelforum.com/member.php...o&userid=24336
View this thread: http://www.excelforum.com/showthread...hreadid=381736

  #7   Report Post  
anilsolipuram
 
Posts: n/a
Default


Just paste at one place in any module, you need not define it in all
modules, you can access from any module

The good thing about function is that it can called from excel cell

like in a2 cell, you type in

=only_text("trrr000rrrr9")

it will return true in the cell if it only text or else false .


--
anilsolipuram
------------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...o&userid=16271
View this thread: http://www.excelforum.com/showthread...hreadid=381736

  #8   Report Post  
thephoenix12
 
Posts: n/a
Default


I am trying to write a simple code like this:


FUNCTION ONLY_TEXT(V AS VARIANT)
DIM P_TEXT AS INTEGER
P_TEXT = 1

FOR I = 1 TO LEN(V)
IF ISNUMERIC(MID(V, I, I + 1)) THEN
P_TEXT = 0
END IF

NEXT
IF P_TEXT = 0 THEN
ONLY_TEXT = FALSE
ELSE
ONLY_TEXT = TRUE
END IF
END FUNCTION

SUB TEXTING()
DIM BLAH AS RANGE
SET BLAH = RANGE(\"A1:A5\")
IF ONLY_TEXT(BLAH) THEN
MSGBOX (\"IT IS ONLY TEXT\")
ELSE
MSGBOX (\"IT CONTAINS SOMETHING ELSE OTHER THAN TEXT\")
END IF
END SUB

but it is not working...it gives me an error at the i part of the
function; any ideas?


--
thephoenix12
------------------------------------------------------------------------
thephoenix12's Profile: http://www.excelforum.com/member.php...o&userid=24336
View this thread: http://www.excelforum.com/showthread...hreadid=381736

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why is the order of my data table opposite from graph? mozermodo Charts and Charting in Excel 6 April 25th 23 03:43 AM
Opposite of SUM function is ?? amkazen Excel Discussion (Misc queries) 1 April 18th 05 07:13 PM
Need opposite of excel function CONCATENATE Adam Excel Discussion (Misc queries) 3 March 5th 05 08:59 PM
return opposite Pat Excel Worksheet Functions 2 January 2nd 05 12:31 AM
The opposite of IF function gives #VALUE for value = 0 gizmo Excel Worksheet Functions 2 December 30th 04 01:36 PM


All times are GMT +1. The time now is 07:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"