Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Remove letters from a cell

Column E of my spreadsheet contains a price. Appended to
the price is a two letter country abbreviation.

E.g 3.50GB
or 2.67EU

I would like to remove any letters but leave the numbers.

One further point to note, trimming the column will not
work as some numbers do not have a country denomination.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Remove letters from a cell

On Fri, 1 Oct 2004 04:37:11 -0700, "Steve"
wrote:

Column E of my spreadsheet contains a price. Appended to
the price is a two letter country abbreviation.

E.g 3.50GB
or 2.67EU

I would like to remove any letters but leave the numbers.

One further point to note, trimming the column will not
work as some numbers do not have a country denomination.


=IF(ISNUMBER(--TRIM(A1)),--A1,--LEFT(TRIM(A1),LEN(TRIM(A1))-2))


--ron
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Remove letters from a cell

Ron

Is it possible to incorporate this into a macro ?

Thanks
Steve
-----Original Message-----
On Fri, 1 Oct 2004 04:37:11 -0700, "Steve"
wrote:

Column E of my spreadsheet contains a price. Appended

to
the price is a two letter country abbreviation.

E.g 3.50GB
or 2.67EU

I would like to remove any letters but leave the numbers.

One further point to note, trimming the column will not
work as some numbers do not have a country denomination.


=IF(ISNUMBER(--TRIM(A1)),--A1,--LEFT(TRIM(A1),LEN(TRIM

(A1))-2))


--ron
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Remove letters from a cell

If IsNumeric(Range("A1")) Then
myVar = Range("A1")
Else
myVar = Left(Trim(Range("A1")), Len(Trim(Range("A1"))) - 2)
End If


--

HTH

RP

"Steve" wrote in message
...
Ron

Is it possible to incorporate this into a macro ?

Thanks
Steve
-----Original Message-----
On Fri, 1 Oct 2004 04:37:11 -0700, "Steve"
wrote:

Column E of my spreadsheet contains a price. Appended

to
the price is a two letter country abbreviation.

E.g 3.50GB
or 2.67EU

I would like to remove any letters but leave the numbers.

One further point to note, trimming the column will not
work as some numbers do not have a country denomination.


=IF(ISNUMBER(--TRIM(A1)),--A1,--LEFT(TRIM(A1),LEN(TRIM

(A1))-2))


--ron
.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Remove letters from a cell

On Fri, 1 Oct 2004 05:41:51 -0700, "Steve"
wrote:

Ron

Is it possible to incorporate this into a macro ?

Thanks
Steve


Oops.

As a macro, even simpler, since the beginning part is always a number:

===============
Function GetNum(rg As String) As Double
GetNum = Val(rg)
End Function
==============
--ron


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Remove letters from a cell

On Fri, 1 Oct 2004 05:41:51 -0700, "Steve"
wrote:

Ron

Is it possible to incorporate this into a macro ?

Thanks
Steve


As a macro, it can be even simpler, since the beginning part is always a
number.

===================

--ron
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Remove letters from a cell

On Fri, 1 Oct 2004 05:41:51 -0700, "Steve"
wrote:

Ron

Is it possible to incorporate this into a macro ?

Thanks



Or, as a SUB to change everything in a selected range:

===============
Sub GetNum()
Dim c As Range
For Each c In Selection
If Val(c) < 0 Then c = Val(c)
Next c
End Sub
===============


--ron
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Remove letters from a cell

Hi Ron,

I like your Val idea, but would your sub not destroy formulae?

Perhaps the following adaptation might be safer:

Sub GetNum()
Dim c As Range
Dim rng As Range

On Error Resume Next
Set rng = Selection.SpecialCells _
(xlConstants, xlTextValues)
On Error GoTo 0
If Not rng Is Nothing Then
For Each c In rng
If Val(c) < 0 Then c = Val(c)
Next c
End If
End Sub


---
Regards,
Norman



"Ron Rosenfeld" wrote in message
...
On Fri, 1 Oct 2004 05:41:51 -0700, "Steve"
wrote:

Ron

Is it possible to incorporate this into a macro ?

Thanks



Or, as a SUB to change everything in a selected range:

===============
Sub GetNum()
Dim c As Range
For Each c In Selection
If Val(c) < 0 Then c = Val(c)
Next c
End Sub
===============


--ron



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Remove letters from a cell

On Sat, 2 Oct 2004 03:52:33 +0100, "Norman Jones"
wrote:

I like your Val idea, but would your sub not destroy formulae?


Yes, the SUB would destroy formulas.

But, not being certain of the setup or desires of the OP, I posted both a UDF
and a SUB.

I suppose another method of writing the sub, and still getting a similar
result, would be something like:

====================
Sub GetNum()
Dim c As Range
For Each c In Selection
If Val(c) < 0 Then c.offset(0,n) = Val(c)
Next c
End Sub
==================

where n is the offset to the column desired for the result.


--ron
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Remove letters from a cell

Hi Steve,

Assume your alphanumeric prices are in cells E2:E100

Sub Tester()
Dim sStr As String
Dim Rng As Range, RCell As Range

Set Rng = Range("E2:E100") '<<<===== CHANGE

For Each RCell In Rng
sStr = RCell.Value
If Not IsEmpty(RCell) Then
If Not IsNumeric(RCell) Then
RCell.Value = CDbl(Left(sStr, Len(sStr) - 2))
End If
End If
Next

End Sub

---
Regards,
Norman



"Steve" wrote in message
...
Column E of my spreadsheet contains a price. Appended to
the price is a two letter country abbreviation.

E.g
or 2.67EU

I would like to remove any letters but leave the numbers.

One further point to note, trimming the column will not
work as some numbers do not have a country denomination.





  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Remove letters from a cell

Thanks Norman
-----Original Message-----
Hi Steve,

Assume your alphanumeric prices are in cells E2:E100

Sub Tester()
Dim sStr As String
Dim Rng As Range, RCell As Range

Set Rng = Range("E2:E100") '<<<===== CHANGE

For Each RCell In Rng
sStr = RCell.Value
If Not IsEmpty(RCell) Then
If Not IsNumeric(RCell) Then
RCell.Value = CDbl(Left(sStr, Len(sStr) -

2))
End If
End If
Next

End Sub

---
Regards,
Norman



"Steve" wrote in

message
...
Column E of my spreadsheet contains a price. Appended

to
the price is a two letter country abbreviation.

E.g
or 2.67EU

I would like to remove any letters but leave the

numbers.

One further point to note, trimming the column will not
work as some numbers do not have a country

denomination.


.

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
remove 1st 2 letters in each row Cathy Excel Discussion (Misc queries) 1 December 15th 09 02:01 PM
Remove/Ignore Letters when Summing cells in a column. Matt Excel Worksheet Functions 3 December 18th 08 06:37 PM
Remove letters from text string John Calder New Users to Excel 3 May 14th 08 12:53 AM
Remove dashes between letters and between letters and digits [email protected] Excel Worksheet Functions 7 March 5th 08 06:08 PM
How can I remove a space between a letters and set of numbers? connie Excel Discussion (Misc queries) 5 July 2nd 07 04:31 PM


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