LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Test a String to see if it begins with a Number

Hi,

I have a long data file that I am trying to format. There are about
2000 lines in the file, all formatted as text upon import. Many of
the lines are simply lines of text that I am trying to remove, the
goal being to leave behind only the lines that actually contain
numeric data. My thought is to test the first character in each row
to see if it begins with an integer between 1 and 9, inclusive. All
lines meeting this criteria are lines that I want to keep. Any lines
that do not are lines that I want to delete. By looping through the
file, I can fairly quickly clean out all of the excess records. Here
is my code so far:

Dim AcctTest As Variant

'Delete lines that don't contain account balances
Sheets("LYBalances").Range("A1").Select
Do While ActiveCell.Value < ""
AcctTest = (Left(ActiveCell.Value, 1))
AcctTest = AcctTest * 1 'to convert the string into a value
If Not AcctTest < 10 Then
Selection.EntireRow.Delete
ActiveCell.Offset(-1, 0).Select
End If
ActiveCell.Offset(1, 0).Select
Loop

Using this method, I think that the basic question is how to convert
this single character into a value that can be interpreted
mathmatically. I've searched through the newsgroup, but can't find
anything that I seems to help.

Also, I'm sure that there are other ways to tackle this, so other
suggestions are welcome.

TIA,
Randy Eastland
 
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
Test String LucB Excel Discussion (Misc queries) 2 November 29th 06 02:49 AM
I want to put a bank account number that begins with 00 in Excel. Kbrookfi Excel Worksheet Functions 1 March 9th 06 05:32 AM
How do I type number that begins with a zero to keep zero? Vickie Newton Excel Discussion (Misc queries) 4 September 19th 05 08:28 PM
Pasting a number to Excel that begins with 0 Tom Excel Discussion (Misc queries) 8 September 13th 05 10:50 PM
How do I type in a number that begins with zero? Blindie00 Excel Discussion (Misc queries) 3 December 19th 04 10:05 AM


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