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: 29
Default Testing length of a number

I need to add text to the beginning of a number if it starts with 7 and has a
length of 5 digits.

Below is what I wrote, but it puts the text in front of every number that
starts with 7, regardless of length. What did I do wrong?

Range("A2").Select
RowCount = 2
'do this as long as there is anything in column A
Do While Range("A" & (RowCount + 1)) < ""
'if PTAN starts with 7 and is 5 digits long, prepend with QQQQQ0
If (Left(Range("B" & RowCount), 1) = 7 And _
(Len(Range("B" & RowCount) = 5))) Then
Range("B" & RowCount) = "QQQQQ0" & Range("B" & RowCount)
RowCount = RowCount + 1
Else
RowCount = RowCount + 1
End If
Loop

The reason I'm doing this is that I need to have the leading zeros retained.
I will then be concatenating the numbers to the first cell in the row (using
the code that Joel so graciously wrote for me), separated by spaces. I will
then replace all the QQQQQ with nothing.

Thank you for your time. Any input is gratefully accepted.

Dee Sperling
 
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
Maximum length of a number Pé Excel Worksheet Functions 1 October 31st 06 11:42 AM
number length limit jhahes[_48_] Excel Programming 2 March 21st 06 11:19 PM
Formating number to fix length kai Excel Programming 4 September 15th 05 08:03 PM
number testing Ben[_5_] Excel Programming 4 August 25th 04 06:53 PM
testing whether a character is a letter or number Paul James[_3_] Excel Programming 9 February 20th 04 12:04 AM


All times are GMT +1. The time now is 04:26 AM.

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"