Help with editing cell with data in excel sheet


I have excel sheet that has a column with words + number, for Example: "Test 1234" or "Test1234" or "Test Test 1234",
I need VBA code which will split the string into columns,
The VBA Code will search the whole column and move the number to the cell next to it.
For example if cell A1 is: "Test 1234" and cell A2 is: "Test 4321" and cells B1 and B2 are empty,
Than this VBA Code will move from A1 "1234" to the B1 cell and from B1 it will move the "4321" to B2,
This code needs to ignore numbers that are smaller than 5 digits and cells with no number at all.
Leon LimbaevAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roy CoxGroup Finance ManagerCommented:
Place this code in a standard module and see if it does what you want
Option Explicit

Sub SplitEntries()
    Dim rRng As Range, rCl As Range
    Dim iX As Integer
    Dim sNum As String
    Set rRng = ActiveSheet.Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp))

    For Each rCl In rRng.Cells
        sNum = ""
        With rCl
            For iX = 1 To Len(.Value)
                'If the character is a number, add it to the sNum variable.
                If IsNumeric(Mid(.Value, iX, 1)) Then sNum = sNum & Mid(.Value, iX, 1)
            Next iX
            If Len(sNum) >= 5 Then
                .Offset(, 1) = sNum
                .Value = Left(.Value, Len(.Value) - Len(sNum))
            End If
        End With
    Next rCl
End Sub

Open in new window

[ fanpages ]IT Services ConsultantCommented:
How does this request differ from your previous question's requirements?

[ ]
Leon LimbaevAuthor Commented:
My previous question's requirements are not for editing, in this question I wrote that I am interesting in editing the cell content.
I was told that editing can be done with VBA code and that's what I am asking in here.
The reason I am not uploading a sample is because it's a very big excel file and it contains sensitive details of my work.
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
No need to upload your original workbook here.
You may create a dummy workbook with some dummy data (as you showed in your first post) and show the desired output. That would help the solution provider to know what exactly you are trying to achieve.

You dummy workbook may contain two sheets "Before" and "After" where you may show what you have originally in Before Sheet and the desired output in the After Sheet.
Leon LimbaevAuthor Commented:
Ok, I attached excel with 2 sheets,
One Shows the before and the second after.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Please find the attached workbook and on Test Sheet click the button "Click Here" to run the code and see if you get the desired output.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.