View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Deleting garbage

My dear Donna :)

you ARE asking in the Programming NG.
so I assume you'd understand that THIS is a macro.

open VBE (alt F11)
insert module
copy/paste my code
probably better to copy the latebound alternative)
posted later

then close vbe
in excel:
select your rangr with junk
run the macro "StrippinJunkLATEBOUND"

DAH!... else goto worksheetfunction NG.
<big grin



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Donna Yawanna wrote :

If I was smart enough to figure out what the heck this stuff was I'd
be able to understand the ISERROR solution. :)

"keepITcool" wrote in message
t.com...



Sub StrippinJunk()
'requires a reference to (viaTools/References):
'Microsoft VBScript Regular Expressions v5.5

Dim re As New RegExp
Dim c As Range
re.Global = True
re.Ignorecase = True
'a or b (repeat exactly 2x)
'0 to 9 (repeat exactly 4x)
re.Pattern = "([ab]{2,2}[0-9]{4,4})|(.?)"

For Each c In Selection.Cells
c.Value = Trim(re.Replace(c.Value, "$1 "))
Next
End Sub




--
keepITcool
www.XLsupport.com | keepITcool chello nl | amsterdam



Sandra wrote :

I have rows that look like this:

junkjunk junk more junk aa1234 still more junk and
even more junk
this is also junk aa4567
and so is this, just junk
junk aabcde junk junk junk junk

And I want to remove all text and spaces except the 6 character
string that starts with aa.
How can I do that? I've looked at Left and Right and other
functions but I think I'm just too dense.