I am using Excel 2013. I want to trim 'words' in Excel that end with numbers, eg:

david22
yuvi1
michell555

to result in:

david   22
yuvi    1
michell 555

Can anyone please help?

有帮助吗?

解决方案

You should try this if you don't want to use vba:

I am assumming your data is in A column, so below formula should be kept at C column, Drag this formula untill your data is there in Column A.

=+SUMPRODUCT(MID(0&A1,LARGE(INDEX(ISNUMBER(--MID(A1,ROW($1:$25),1))*ROW($1:$25),0),ROW($1:$25))+1,1)*10^ROW($1:$25)/10)

THEN

use the below formula in column B and drag it to last.

=LEFT(A1,SEARCH(C1,A1)-1)

Hope this helps

Attached is screenshot for your reference.

enter image description here

Some Caveat:

1) - The input string in column A must be shorter than 25 characters

2) - There must be at most 14 digits in the input string. (Any following digits will be shown as zeroes.)

But for the question you asked it should work perfectly fine.

其他提示

There is lot of examples available in Web ..

Let say u have a data in A column with Header ..

The below work splits text in b column , numbers in c column

Sub Seperate()
Dim r As Range, rC As Range
Dim v As Variant

Set r = Range("A2", Range("A2").End(xlDown))
With CreateObject("VBScript.RegExp")
    .Pattern = "(\d+|\D+)"
    .Global = True
    For Each rC In r
        v = Split(Mid(.Replace(rC.Value, "|$1"), 2), "|")
        rC.Offset(, 1).Resize(, UBound(v) + 1).Value = v
    Next rC
End With
End Sub

Copy and Paste Special in to Word as Unformatted Text. With Use wildcards Find what: ([A-z])([0-9]) and Replace All with Replace with: \1 \2. Copy results back into Excel and apply Text to Columns with space as the delimiter.

The text editor Vi or Vim can do this work.

Line 1: age231

Line 2: open432

Line 3: bit042

The command 1,3s/\(\D\)\(\d\)/\1\t\2/g in the command mode can do what you want.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top