Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default 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
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
Wildcard search for string within a string? Ed Excel Programming 0 June 8th 06 11:28 PM
to search for a string and affect data if it finds the string? Shwaman Excel Worksheet Functions 1 January 11th 06 12:56 AM
search a string withing a string : find / search hangs itarnak[_9_] Excel Programming 4 October 24th 05 03:19 PM
VBA function : How to search a string in another string? bibi-phoque Excel Programming 5 April 19th 05 06:24 PM
Excel XP VBA code to search all macro code in Excel module for specific search string criteria Frank Kabel Excel Programming 0 May 19th 04 08:11 PM


All times are GMT +1. The time now is 04:08 PM.

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

About Us

"It's about Microsoft Excel"