Solved

select specific numbers from a column of numbers in excel

Posted on 2012-03-26
10
232 Views
Last Modified: 2012-03-27
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.
0
Comment
Question by:gregfthompson
  • 5
  • 5
10 Comments
 
LVL 46

Expert Comment

by:Martin Liss
ID: 37769343
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
0
 

Author Comment

by:gregfthompson
ID: 37769418
Thanks MartinLiss.

Can you amend the file and attach?

Greg
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 37769426
I'm sorry but what file? Did you mean to attach one?
0
 

Author Comment

by:gregfthompson
ID: 37769446
I've amended the file to have the original column is now A.

Can you include the macro? File is attached.

Thanks,

Greg
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 37769451
Sorry but there's still no file attached. And I'm on my way out the door for the night… sorry.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:gregfthompson
ID: 37769480
Sorry. Here it is.  I am unable to make it work.
Number-split.xlsm
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 37769497
I put data in col A and it worked just fine. Did you notice that it is code for a command button?
0
 

Author Comment

by:gregfthompson
ID: 37770623
Can you upload the file?
0
 
LVL 46

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 37771596
Okay here it is.Number-split.xlsm
0
 

Author Closing Comment

by:gregfthompson
ID: 37773556
Thank you!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now