Cigar Asylum Cigar Forum  

Go Back   Cigar Asylum Cigar Forum > Non Cigar Specialty Forums > Misc > General Discussion

Reply
 
Thread Tools Display Modes
Old 07-11-2012, 10:16 AM   #1
markem
Bunion
 
markem's Avatar
16
 
Join Date: Oct 2008
First Name: Mark
Location: Second Star on the Right
Posts: 22,546
Trading: (47)
HUpmann
markem has disabled reputation
Default MS Excel cleanup routine

I have never written a cleanup routine for excel. All that I have done it write formulas and such.

I find myself in need of a routine that can be run over a set of cells (usually a column) that will strip out an extraneous character from the data set. The specific need at the moment is that I am copying a web page of financial data but the way that the financial institution puts the data up, I wind up with a tab character as part of each column. This isn't too bad except for the columns that contain numbers. I'd like a way to delete the trailing tab character or (much better) remove any non-number from the column/set. Of course, I'd like to keep the '-' sign for negative numbers.

Is there a macro already in MS land that can do this or can anyone give me an idea as to where to go to get the information or, if it is that simple, just post one?

Thanks in advance!!
__________________
I refuse to belong to any organization that would have me as a member.
~ Groucho Marx
markem is offline   Reply With Quote
Old 07-11-2012, 11:19 AM   #2
CigarNut
F*ck Cancer!
 
CigarNut's Avatar
16
 
Join Date: Jan 2009
First Name: Michael
Location: Clermont, Florida
Posts: 18,038
Trading: (111)
RA
CigarNut has disabled reputation
Default Re: MS Excel cleanup routine

Not sure how to do this with a canned macro, but I can write a VB macro do do this... Something like this clears the contents of column 2, rows 1 through 100:
Sub cleanup()
Dim i
For i = 1 To 100
' this clears the cell, but you can use simple or regular expressions to edit.
Cells(i, 2).Value = ""
Next
End Sub
__________________
Need Beads? Need Five Finger Bags?

2 of 3 Requirements for use of the CA Rolodex: 100 posts/ 60 day membership/ participation in trade (trader rating). New members can be added at any time.
CigarNut is offline   Reply With Quote
Old 07-11-2012, 11:23 AM   #3
markem
Bunion
 
markem's Avatar
16
 
Join Date: Oct 2008
First Name: Mark
Location: Second Star on the Right
Posts: 22,546
Trading: (47)
HUpmann
markem has disabled reputation
Default Re: MS Excel cleanup routine

Thanks, Michael. However, I am trying to take a cell with a number that looks like "123 " (note the space at the end) and removes all non-numbers to get "123" (no space). It's easy to do in C, since isanumber is there. There are specific instances where the number might not be terminated by a space, so I can't just delete the last character of the string. Also, I suspect that sometimes, that space is a tab.
__________________
I refuse to belong to any organization that would have me as a member.
~ Groucho Marx
markem is offline   Reply With Quote
Old 07-11-2012, 11:43 AM   #4
mmblz
.090909...
 
mmblz's Avatar
 
Join Date: Oct 2008
Location: NH
Posts: 4,031
Trading: (3)
Partagas
mmblz has disabled reputation
Default Re: MS Excel cleanup routine

TRIM should remove leading and trailing spaces.
Not sure if you anticipate "internal" spaces? Letters?
__________________
herf wear
mmblz is offline   Reply With Quote
Old 07-11-2012, 11:49 AM   #5
mmblz
.090909...
 
mmblz's Avatar
 
Join Date: Oct 2008
Location: NH
Posts: 4,031
Trading: (3)
Partagas
mmblz has disabled reputation
Default Re: MS Excel cleanup routine

or use regexp - see the second answer here:
http://stackoverflow.com/questions/3...ction-or-regex

to remove anything but digits use \D instead of \d
__________________
herf wear
mmblz is offline   Reply With Quote
Old 07-11-2012, 12:12 PM   #6
markem
Bunion
 
markem's Avatar
16
 
Join Date: Oct 2008
First Name: Mark
Location: Second Star on the Right
Posts: 22,546
Trading: (47)
HUpmann
markem has disabled reputation
Default Re: MS Excel cleanup routine

Thanks, Julian. Looks like trim() will work, but I also played with the regex routine you pointed me to.
__________________
I refuse to belong to any organization that would have me as a member.
~ Groucho Marx
markem is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -6. The time now is 12:51 AM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
All content is copyrighted jointly by Cigar Asylum and the content provider.