Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 192
Default Keep string without rightmost letters

I have a huge list of products that have different model types denoted by
letters at the end of the product i.e.
ProductA 5760tr
ProductA 5760xsn
etc.

I eventually want to do a vlookup but only have "ProductA 5760" in my data
to be pulled from. Can I get rid of all the letters after the numbers even
if they're variable in length?

What I have:
ProductA 5760tr
ProductA 5760xsn
ProductB 7560tr

What I want:
ProductA 5760
ProductA 5760
ProductB 7560

Thanks for any help!
--
-SA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Keep string without rightmost letters

The following UDF starts at the end of the string and discards characters
until it finds a numeral:

Function strip_it(r As Range) As String
v = r.Value
L = Len(v)
For i = 1 To L
If Not IsNumeric(Right(v, 1)) Then
v = Left(v, Len(v) - 1)
Else
Exit For
End If
Next
strip_it = v
End Function

--
Gary''s Student - gsnu200795


"StumpedAgain" wrote:

I have a huge list of products that have different model types denoted by
letters at the end of the product i.e.
ProductA 5760tr
ProductA 5760xsn
etc.

I eventually want to do a vlookup but only have "ProductA 5760" in my data
to be pulled from. Can I get rid of all the letters after the numbers even
if they're variable in length?

What I have:
ProductA 5760tr
ProductA 5760xsn
ProductB 7560tr

What I want:
ProductA 5760
ProductA 5760
ProductB 7560

Thanks for any help!
--
-SA

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Keep string without rightmost letters

You could use this array-entered** formula to get the part of the text you
want...

=LEFT(A1,MAX(ISNUMBER(--MID(A1,ROW($1:$99),1))*ROW($1:$99)))

** Commit this formula using Ctrl+Shift+Enter, not just Enter by itself.

The 99 in the two occurrences of ROW($1:$99) within the formula only need to
be a number larger than the maximum number of characters you will ever
expect to have in one of your products.

Rick


"StumpedAgain" wrote in message
...
I have a huge list of products that have different model types denoted by
letters at the end of the product i.e.
ProductA 5760tr
ProductA 5760xsn
etc.

I eventually want to do a vlookup but only have "ProductA 5760" in my data
to be pulled from. Can I get rid of all the letters after the numbers
even
if they're variable in length?

What I have:
ProductA 5760tr
ProductA 5760xsn
ProductB 7560tr

What I want:
ProductA 5760
ProductA 5760
ProductB 7560

Thanks for any help!
--
-SA


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 192
Default Keep string without rightmost letters

Nice! I had to change

If Not IsNumeric(Right(v, 1)) Then
to
If IsNumeric(Right(v, 1)) = False Then

but other than that, worked like a charm. Thanks!

--
-SA


"Gary''s Student" wrote:

The following UDF starts at the end of the string and discards characters
until it finds a numeral:

Function strip_it(r As Range) As String
v = r.Value
L = Len(v)
For i = 1 To L
If Not IsNumeric(Right(v, 1)) Then
v = Left(v, Len(v) - 1)
Else
Exit For
End If
Next
strip_it = v
End Function

--
Gary''s Student - gsnu200795


"StumpedAgain" wrote:

I have a huge list of products that have different model types denoted by
letters at the end of the product i.e.
ProductA 5760tr
ProductA 5760xsn
etc.

I eventually want to do a vlookup but only have "ProductA 5760" in my data
to be pulled from. Can I get rid of all the letters after the numbers even
if they're variable in length?

What I have:
ProductA 5760tr
ProductA 5760xsn
ProductB 7560tr

What I want:
ProductA 5760
ProductA 5760
ProductB 7560

Thanks for any help!
--
-SA

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Keep string without rightmost letters

if u have always productA, B, C etc why dont u try left(range;11)
mcg

Użytkownik "StumpedAgain" napisał w
wiadomo¶ci ...
I have a huge list of products that have different model types denoted by
letters at the end of the product i.e.
ProductA 5760tr
ProductA 5760xsn
etc.

I eventually want to do a vlookup but only have "ProductA 5760" in my data
to be pulled from. Can I get rid of all the letters after the numbers
even
if they're variable in length?

What I have:
ProductA 5760tr
ProductA 5760xsn
ProductB 7560tr

What I want:
ProductA 5760
ProductA 5760
ProductB 7560

Thanks for any help!
--
-SA



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
Name a sheet using letters from a string? [email protected] Excel Programming 1 April 6th 07 04:41 PM
Breaking a string of letters Confused Excel Discussion (Misc queries) 2 March 10th 07 11:49 AM
Breaking a string of letters john Excel Discussion (Misc queries) 0 March 8th 07 07:31 PM
# of letters in a string DejaVu[_43_] Excel Programming 4 August 8th 05 02:59 PM
Calculating number of letters in a string ... Larry Wallis Excel Worksheet Functions 4 February 17th 05 10:11 AM


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