Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Convert numeric part of text to number

I am combining 2 lists in 2 columns in XL. The index in both lists is
in the format: 01-Adams. There is one for each county in the state. I
want to know how to convert the 01 text part to a numeric value to
compare to another one and determine where they should be in a table.
If I do a

strOrigCtyNo = Right(strOrig, Len(strOrig) + 2)

I believe it will give me the first 2 characters of the code. How do I
convert them to an integer constant to compare them, or do I even have
to? If I remember right from my old programming days, comparing numbers
in ASCII sometimes gives different results from comparing numbers. Is
that still true in VBA? What is the best way to proceed here?
Thanks again!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Convert numeric part of text to number

in VBA there are functions CInt, CDbl, ... which convert text to value. You
should be albe to use CInt to convert teh first two digits to an number.
--
HTH...

Jim Thomlinson


"davegb" wrote:

I am combining 2 lists in 2 columns in XL. The index in both lists is
in the format: 01-Adams. There is one for each county in the state. I
want to know how to convert the 01 text part to a numeric value to
compare to another one and determine where they should be in a table.
If I do a

strOrigCtyNo = Right(strOrig, Len(strOrig) + 2)

I believe it will give me the first 2 characters of the code. How do I
convert them to an integer constant to compare them, or do I even have
to? If I remember right from my old programming days, comparing numbers
in ASCII sometimes gives different results from comparing numbers. Is
that still true in VBA? What is the best way to proceed here?
Thanks again!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Convert numeric part of text to number


Jim Thomlinson wrote:
in VBA there are functions CInt, CDbl, ... which convert text to value. You
should be albe to use CInt to convert teh first two digits to an number.
--
HTH...

Jim Thomlinson


"davegb" wrote:

I am combining 2 lists in 2 columns in XL. The index in both lists is
in the format: 01-Adams. There is one for each county in the state. I
want to know how to convert the 01 text part to a numeric value to
compare to another one and determine where they should be in a table.
If I do a

strOrigCtyNo = Right(strOrig, Len(strOrig) + 2)

I believe it will give me the first 2 characters of the code. How do I
convert them to an integer constant to compare them, or do I even have
to? If I remember right from my old programming days, comparing numbers
in ASCII sometimes gives different results from comparing numbers. Is
that still true in VBA? What is the best way to proceed here?
Thanks again!



Thanks, Jim!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Convert numeric part of text to number

if the first two digits are on the left side of the string, I don't think
this is what you want:
strOrigCtyNo = Right(strOrig, Len(strOrig) + 2)


strOrigCtyNo = Left(strOrig,2)

a way to do the conversion would be

Dim lngOrigCityNo as Long
lngOrigCityNo = Left(strOrig,2)

--
Regards,
Tom Ogilvy

"davegb" wrote in message
oups.com...

Jim Thomlinson wrote:
in VBA there are functions CInt, CDbl, ... which convert text to value.

You
should be albe to use CInt to convert teh first two digits to an number.
--
HTH...

Jim Thomlinson


"davegb" wrote:

I am combining 2 lists in 2 columns in XL. The index in both lists is
in the format: 01-Adams. There is one for each county in the state. I
want to know how to convert the 01 text part to a numeric value to
compare to another one and determine where they should be in a table.
If I do a

strOrigCtyNo = Right(strOrig, Len(strOrig) + 2)

I believe it will give me the first 2 characters of the code. How do I
convert them to an integer constant to compare them, or do I even have
to? If I remember right from my old programming days, comparing

numbers
in ASCII sometimes gives different results from comparing numbers. Is
that still true in VBA? What is the best way to proceed here?
Thanks again!



Thanks, Jim!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Convert numeric part of text to number

Thanks again, Tom!



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
convert a numeric number in text format in another cell? Abhishek Excel Worksheet Functions 2 February 22nd 07 05:44 PM
Extract just numeric part of mixed text/number entry? Heidi Excel Worksheet Functions 7 June 1st 06 07:33 PM
Numeric in Text to convert back to the form of Numeric for VLookup Purposes achilles Excel Discussion (Misc queries) 4 February 6th 06 07:05 AM
how can I convert numeric number into text firas Excel Discussion (Misc queries) 1 September 21st 05 07:05 PM
convert a number in Excel from numeric to text, i.e. "1" to "one" buenavisionpaul Excel Worksheet Functions 1 January 27th 05 06:30 PM


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