Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Trimming Email addresses

Hi,
I have a column with Email addresses like:
Email
Email
nbsp Please send written requests to <sjohnson@usaid
TO .

I nee to trim them on both sides so I will have only Email address and
nothing else.
I used this:
Sub trimcells()
For Each cel In Selection
cel.Value = Trim(Right(cel, Len(cel)""), Left(cel, Len(cel)"<"))
Next cel
End Sub
It doesn't work.
I will appreciate any help.
Thank you.
Oxana.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Trimming Email addresses

Sub trimcells()
dim iloc as Integer, iloc1 as integer
Dim cel as Range
For Each cel In Selection
iloc = Instr(cel.Value, "<")
iloc1 = Instr(cel.Value,"")
if iloc < 0 and iloc1 < 0 and iloc1 iloc then
cel.Value = Mid(cel.value, iloc+1, iloc1-iloc-1)
end if
Next Cel
End Sub

--
Regards,
Tom Ogilvy


"OxanaB" wrote in message
...
Hi,
I have a column with Email addresses like:
Email
Email
nbsp Please send written requests to <sjohnson@usaid
TO .

I nee to trim them on both sides so I will have only Email address and
nothing else.
I used this:
Sub trimcells()
For Each cel In Selection
cel.Value = Trim(Right(cel, Len(cel)""), Left(cel, Len(cel)"<"))
Next cel
End Sub
It doesn't work.
I will appreciate any help.
Thank you.
Oxana.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Trimming Email addresses

Hi

Should your line of code
cel.Value = Trim(Right(cel, Len(cel)""), Left(cel, Len(cel)"<"))


be replaced by
OldValu = CStr(Cel.Value)
LeftPOS = INSTR(1,OldValu,"<", vbTextOnly)
RightPOS = INSTR(1,OldValu,"", vbTextOnly)
NewValu = TRIM(MID(OldValu,LeftPOS+1,(RightPOS-LeftPOS)))

or something close to it
regards
"OxanaB" wrote:

Hi,
I have a column with Email addresses like:
Email
Email
nbsp Please send written requests to <sjohnson@usaid
TO .

I nee to trim them on both sides so I will have only Email address and
nothing else.
I used this:
Sub trimcells()
For Each cel In Selection
cel.Value = Trim(Right(cel, Len(cel)""), Left(cel, Len(cel)"<"))
Next cel
End Sub
It doesn't work.
I will appreciate any help.
Thank you.
Oxana.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Macro how to create email link for the email addresses in aRange or Selection Satish[_2_] Excel Worksheet Functions 8 December 28th 09 03:30 PM
can I copy a column of email addresses, paste into email address? Lizizfree New Users to Excel 4 July 20th 06 10:03 PM
Email addresses in Excel need to format for mass email Boomer Excel Worksheet Functions 1 June 9th 06 01:46 PM
Transfer Email addresses from spreadsheet to email address book Beana Excel Discussion (Misc queries) 2 May 30th 06 06:07 PM
Move a Column of 500 Email Addresses into BCC Field of an Email Mark Excel Worksheet Functions 9 July 27th 05 05:07 AM


All times are GMT +1. The time now is 05:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"