Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need to search a string for numbers
Hi all! What I am trying to do sounds like it should be easy, but it is not
working for me...Here is what I am trying to do... User pushes a button that brings up an input box, the value typed in that is saved as 'ColumnBox'. I then Want to check ColumnBox to see if it has numbers in it, if it does, I want to produce an error (which I can do the error part fine), or if there is no number than continue the procedure. Any ideas? Ive been trying combonations of InStr and Isnumeric, but nothing works 100% |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need to search a string for numbers
Try this code as an example
Sub NumericCheck() Dim mString As String, mChar As String Dim i As Integer mString = InputBox("Enter in a String") For i = 1 To Len(mString) mChar = Mid(mString, i, 1) If IsNumeric(mChar) Then MsgBox "This string has numbers in it" Exit Sub End If Next i MsgBox "This string conatined no numbers" End Sub Sandy havocdragon wrote: Hi all! What I am trying to do sounds like it should be easy, but it is not working for me...Here is what I am trying to do... User pushes a button that brings up an input box, the value typed in that is saved as 'ColumnBox'. I then Want to check ColumnBox to see if it has numbers in it, if it does, I want to produce an error (which I can do the error part fine), or if there is no number than continue the procedure. Any ideas? Ive been trying combonations of InStr and Isnumeric, but nothing works 100% |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need to search a string for numbers
another way...
Sub TellMeNoLies() Dim ColumnBox As String ColumnBox = "23Skidoo" If ColumnBox Like "*#*" Then MsgBox "No numbers ", vbExclamation Else MsgBox "Please continue ", vbInformation End If End Sub -- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware "havocdragon" wrote in message Hi all! What I am trying to do sounds like it should be easy, but it is not working for me...Here is what I am trying to do... User pushes a button that brings up an input box, the value typed in that is saved as 'ColumnBox'. I then Want to check ColumnBox to see if it has numbers in it, if it does, I want to produce an error (which I can do the error part fine), or if there is no number than continue the procedure. Any ideas? Ive been trying combonations of InStr and Isnumeric, but nothing works 100% |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need to search a string for numbers
lol, sandy thats almost exactly what I did after I posted this...Jim,
thanks!! that works even better...I can't beleive I didnt think of that seeing as I format stuff as numbers in code all the time... "Jim Cone" wrote: another way... Sub TellMeNoLies() Dim ColumnBox As String ColumnBox = "23Skidoo" If ColumnBox Like "*#*" Then MsgBox "No numbers ", vbExclamation Else MsgBox "Please continue ", vbInformation End If End Sub -- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware "havocdragon" wrote in message Hi all! What I am trying to do sounds like it should be easy, but it is not working for me...Here is what I am trying to do... User pushes a button that brings up an input box, the value typed in that is saved as 'ColumnBox'. I then Want to check ColumnBox to see if it has numbers in it, if it does, I want to produce an error (which I can do the error part fine), or if there is no number than continue the procedure. Any ideas? Ive been trying combonations of InStr and Isnumeric, but nothing works 100% |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need to search a string for numbers
so I will go one further now, I have the code that does this but its alot
larger than I would like. What I need it to prevent is; Numbers, Characters, things longer than 2 characters. So basically nothing more than a combination of 2 letters...else... "havocdragon" wrote: lol, sandy thats almost exactly what I did after I posted this...Jim, thanks!! that works even better...I can't beleive I didnt think of that seeing as I format stuff as numbers in code all the time... "Jim Cone" wrote: another way... Sub TellMeNoLies() Dim ColumnBox As String ColumnBox = "23Skidoo" If ColumnBox Like "*#*" Then MsgBox "No numbers ", vbExclamation Else MsgBox "Please continue ", vbInformation End If End Sub -- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware "havocdragon" wrote in message Hi all! What I am trying to do sounds like it should be easy, but it is not working for me...Here is what I am trying to do... User pushes a button that brings up an input box, the value typed in that is saved as 'ColumnBox'. I then Want to check ColumnBox to see if it has numbers in it, if it does, I want to produce an error (which I can do the error part fine), or if there is no number than continue the procedure. Any ideas? Ive been trying combonations of InStr and Isnumeric, but nothing works 100% |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Wildcard search for string within a string? | Excel Programming | |||
to search for a string and affect data if it finds the string? | Excel Worksheet Functions | |||
search a string withing a string : find / search hangs | Excel Programming | |||
VBA function : How to search a string in another string? | Excel Programming | |||
Excel XP VBA code to search all macro code in Excel module for specific search string criteria | Excel Programming |