Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have a column with Email addresses like: 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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: 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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: 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Using Macro how to create email link for the email addresses in aRange or Selection | Excel Worksheet Functions | |||
can I copy a column of email addresses, paste into email address? | New Users to Excel | |||
Email addresses in Excel need to format for mass email | Excel Worksheet Functions | |||
Transfer Email addresses from spreadsheet to email address book | Excel Discussion (Misc queries) | |||
Move a Column of 500 Email Addresses into BCC Field of an Email | Excel Worksheet Functions |