Link to home
Start Free TrialLog in
Avatar of gregfthompson
gregfthompsonFlag for Australia

asked on

select specific numbers from a column of numbers in excel

There is a column of numbers like this "19840: [6396".  I am seeking a script that will copy the last four numbers into a separate column.
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Assuming the data is in col A and you want the new data in B then…


Private Sub CommandButton1_Click()
Dim r As Range
Dim i As Long

Set r = Range("A1").End(xlDown).Offset(0, 0)
For i = 1 To r.Row

    Range("B" & i).Value = Right(Range("A" & i).Value, 4)

Next

End Sub
Avatar of gregfthompson

ASKER

Thanks MartinLiss.

Can you amend the file and attach?

Greg
I'm sorry but what file? Did you mean to attach one?
I've amended the file to have the original column is now A.

Can you include the macro? File is attached.

Thanks,

Greg
Sorry but there's still no file attached. And I'm on my way out the door for the night… sorry.
Sorry. Here it is.  I am unable to make it work.
Number-split.xlsm
I put data in col A and it worked just fine. Did you notice that it is code for a command button?
Can you upload the file?
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you!