Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default HELP I need a function or macro to crop cells

Example If cell A1= STEPHEN R WILSON
I would like A1=STEPHEN WILSON

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default HELP I need a function or macro to crop cells

=LEFT(A1,FIND(" ",A1))&MID(A1,FIND("~",SUBSTITUTE(A1,"
","~",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))+1,255)

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"Shani" wrote in message
oups.com...
Example If cell A1= STEPHEN R WILSON
I would like A1=STEPHEN WILSON



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default HELP I need a function or macro to crop cells

more examples would help - are they all first name initial last name,
or do we have some with more initials, no initials etc?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default HELP I need a function or macro to crop cells

Try some code like


Dim Pos1 As Long
Dim Pos2 As Long
Pos1 = InStr(1, Range("A1").Text, " ")
If Pos1 = 0 Then
Exit Sub
End If
Pos2 = InStr(Pos1 + 1, Range("A1").Text, " ")
If Pos2 = 0 Then
Exit Sub
End If

Range("A1").Value = Left(Range("A1").Text, Pos1 - 1) & " " _
& Mid(Range("A1").Text, Pos2 + 1)





--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Shani" wrote in message
oups.com...
Example If cell A1= STEPHEN R WILSON
I would like A1=STEPHEN WILSON



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default HELP I need a function or macro to crop cells

Sub BBB()
Dim s As String, iloc As Long
Dim iloc1 As Long
s = Range("A1").Value
iloc = InStr(1, s, " ", vbTextCompare)
iloc1 = InStr(iloc + 1, s, " ", vbTextCompare)
Range("A1") = Left(s, iloc) & Right(s, Len(s) - iloc1)

End Sub

--
Regards,
Tom Ogilvy


"Shani" wrote:

Example If cell A1= STEPHEN R WILSON
I would like A1=STEPHEN WILSON




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default HELP I need a function or macro to crop cells

Thank you all

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
crop away the letters Fan924 Excel Discussion (Misc queries) 4 June 15th 09 05:51 PM
crop AutoCAD object jerryk571 Excel Discussion (Misc queries) 0 January 21st 09 06:33 PM
crop spreadsheet bekwud New Users to Excel 11 September 17th 06 10:35 PM
Crop Text to Col Width [email protected] Excel Programming 1 November 17th 05 08:02 PM
Any function for Crop/Cut Text 0-0 Wai Wai ^-^ Excel Worksheet Functions 1 September 8th 05 01:29 PM


All times are GMT +1. The time now is 03:45 AM.

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"