Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem: error on numeric

Howdy,

Let me thank you before-hand for any help you can give me.

I wrote a program that uses two long lists of DBL numeric values. The
problem is that sometimes the information I paste into my program is non-
numeric (When they give me bad data). When ever I paste a value with even 1
non-numeric character somewhere in it, it blows up with the Type Mismatch
error.

What I need to do is come up with some basic error handling code, but hell if
I know what works.

I am using this code to take off the first two letters if they are alphabetic:

-------------------------------------------------------------
Do Until IsEmpty(ActiveCell)
ActiveCell.NumberFormat = "@"
If Mid(ActiveCell.Value, 1, 1) Like "[A-Za-z]" And Mid(ActiveCell.Value,
2, 1) Like "[A-Za-z]" Then
ActiveCell.Value = (Mid(ActiveCell.Value, 3, Len(ActiveCell.Value) -
2))
End If

<--------------------------------Maybe I can put the code
here?

ActiveCell.Offset(1, 0).Select
Loop
-------------------------------------------------------------

What is the best way to scan through the selected cell for any character that
is not a number or a space and then stop the program and pop up a message box
with a message about the error?

Thanks again for any help,
William

--
Message posted via http://www.officekb.com
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default Problem: error on numeric

Hi William,
When you loop through a worksheet, it is faster if you don't "cell offset"
in the loop.
If you are testing for entries in column A, you can count the rows with data
in column A and then loop through each one "virtually."
Perhaps the code below will work for you.

NumRows = Range("A65536").End(xlUp).Row
For Iloop = 1 To NumRows
If Not IsNumeric(Cells(Iloop, "A")) Then
Ans = MsgBox("Cell 'A" & Iloop & "' does not appear to be a
number.",_ vbOKOnly)
End If
Next Iloop

--
Ken Hudson


"willz99ta" wrote:

Howdy,

Let me thank you before-hand for any help you can give me.

I wrote a program that uses two long lists of DBL numeric values. The
problem is that sometimes the information I paste into my program is non-
numeric (When they give me bad data). When ever I paste a value with even 1
non-numeric character somewhere in it, it blows up with the Type Mismatch
error.

What I need to do is come up with some basic error handling code, but hell if
I know what works.

I am using this code to take off the first two letters if they are alphabetic:

-------------------------------------------------------------
Do Until IsEmpty(ActiveCell)
ActiveCell.NumberFormat = "@"
If Mid(ActiveCell.Value, 1, 1) Like "[A-Za-z]" And Mid(ActiveCell.Value,
2, 1) Like "[A-Za-z]" Then
ActiveCell.Value = (Mid(ActiveCell.Value, 3, Len(ActiveCell.Value) -
2))
End If

<--------------------------------Maybe I can put the code
here?

ActiveCell.Offset(1, 0).Select
Loop
-------------------------------------------------------------

What is the best way to scan through the selected cell for any character that
is not a number or a space and then stop the program and pop up a message box
with a message about the error?

Thanks again for any help,
William

--
Message posted via http://www.officekb.com

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
Numeric Data Entry problem NukeTony Excel Discussion (Misc queries) 2 May 2nd 08 02:50 PM
convert numeric value to words, error msg! HHTrang Excel Discussion (Misc queries) 2 April 13th 06 08:42 AM
Numeric field overflow. (Error 3349) [email protected] Excel Programming 1 June 10th 05 08:06 AM
Numeric formatting problem Metolius Dad Excel Worksheet Functions 3 May 22nd 05 07:14 PM
Personnal certificate and numeric signature problem Pierre Archambault Excel Programming 0 May 21st 04 09:28 PM


All times are GMT +1. The time now is 09:41 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"