ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Trimming text contained in cells (https://www.excelbanter.com/excel-programming/301097-trimming-text-contained-cells.html)

ToddG

Trimming text contained in cells
 
Is this even possible?

I have a list of sizes contained in cells in Column C.

Column C
4 x 32 x 1
16 x 32 x 1.25
14.375 x 23 x 1.25
6.5 x 52 x 1.25
4.5 x 23 x 1.25
2.5 x 23 x 1.25

What I need to do is look at each populated cell in Column
C and remove the first number, the space following the
first number, the "x", and the space following the "x" so
I will end up with this:

Column C
32 x 1
32 x 1.25
23 x 1.25
52 x 1.25
23 x 1.25
23 x 1.25

This one is WAY beyond me, any help would be appreciated.




Norman Jones

Trimming text contained in cells
 
Hi Todd,

Try:

Sub Tester()

Dim Rng As Range, cell As Range
Dim pos As Long

Set Rng = ActiveSheet.Range("C2:C100") '<=== CHANGE!
For Each cell In Rng
pos = InStr(1, cell.Value, "x")
cell.Value = Right(cell.Value, Len(cell.Value) - pos)
Next
End Sub


Change the range address to your needs.


---
Regards,
Norman


"ToddG" wrote in message
...
Is this even possible?

I have a list of sizes contained in cells in Column C.

Column C
4 x 32 x 1
16 x 32 x 1.25
14.375 x 23 x 1.25
6.5 x 52 x 1.25
4.5 x 23 x 1.25
2.5 x 23 x 1.25

What I need to do is look at each populated cell in Column
C and remove the first number, the space following the
first number, the "x", and the space following the "x" so
I will end up with this:

Column C
32 x 1
32 x 1.25
23 x 1.25
52 x 1.25
23 x 1.25
23 x 1.25

This one is WAY beyond me, any help would be appreciated.






Soo Cheon Jheong

Trimming text contained in cells
 
Hi,

Try:

Dim RNG As Range
Dim CL As Range
Dim N As Long
Set RNG = ActiveSheet.Range("C2:C100")

For Each CL In RNG
If UCase(CL) Like "*X*X*" Then
N = InStr(1, UCase(CL), "X", vbTextCompare)
CL.Value = Trim(Mid(CL, N + 1, Len(CL)))
End If
Next


--
Regards,
Soo Cheon Jheong
Seoul, Korea
_ _
^вп^
--




All times are GMT +1. The time now is 10:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com