Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jh jh is offline
external usenet poster
 
Posts: 1
Default Extract date from right to left in a cell

I have an excel spreadsheet containing numerous cells. I need to
extract the right most word in each cell. The lengths and number of
spaces vary between cells, so I need a function that will read from
right to left until a space is encountered. Any help will be greatly
appreciated.

J
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Extract date from right to left in a cell


J

Bob Umlas seems to have this answered very well a
http://www.emailoffice.com/excel/arrays-bobumlas.html.

Hope it helps

--
Kiera

Born ignorant and still perfecting the ar
-----------------------------------------------------------------------
Kieran's Profile: http://www.excelforum.com/member.php...nfo&userid=124
View this thread: http://www.excelforum.com/showthread.php?threadid=27407

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Extract date from right to left in a cell

if you have excel 2000, use InstrRev

iloc = InstrRev(cell.Value," ")
lastword = right(cell.Value,Len(cell.value)-iloc)
--
Regards,

"jh" wrote in message
om...
I have an excel spreadsheet containing numerous cells. I need to
extract the right most word in each cell. The lengths and number of
spaces vary between cells, so I need a function that will read from
right to left until a space is encountered. Any help will be greatly
appreciated.

J



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Extract date from right to left in a cell

Hi JH,

Try:

Sub Tester()
Dim sStr As String, oldStr As String
Dim iPos As Long
Dim Rng As Range, Rng2 As Range, rCell As Range

Set Rng = Range("A1:A100") '<<=== CHANGE
On Error Resume Next
Set Rng2 = Rng.SpecialCells(xlCellTypeConstants, _
xlTextValues)
On Error GoTo 0
If Not Rng2 Is Nothing Then
For Each rCell In Rng2
oldStr = rCell.Text
iPos = InStrRev(oldStr, " ")
sStr = Mid(oldStr, iPos + 1)
MsgBox sStr
Next rCell
End If
End Sub

Change Rng = Range("A1:A100") to suit your needs.

---
Regards,
Norman



"jh" wrote in message
om...
I have an excel spreadsheet containing numerous cells. I need to
extract the right most word in each cell. The lengths and number of
spaces vary between cells, so I need a function that will read from
right to left until a space is encountered. Any help will be greatly
appreciated.

J



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Extract date from right to left in a cell

Looks like there's already some answers here, but I'll throw mine out there
for you also (paste into a module and use it as a function in the workbook):

Function RIGHTWORD(rng As Range)

If rng.Cells.Count 1 Then RIGHTWORD = CVErr(xlErrValue)

If IsEmpty(rng.Value) Then RIGHTWORD = ""

RIGHTWORD = Right(rng.Value, Len(rng.Value) - InStrRev(rng.Value, " "))

End Function

-erik

"jh" wrote in message
om...
I have an excel spreadsheet containing numerous cells. I need to
extract the right most word in each cell. The lengths and number of
spaces vary between cells, so I need a function that will read from
right to left until a space is encountered. Any help will be greatly
appreciated.

J





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
Extract Text with Left, Mid, etc berniean Excel Worksheet Functions 8 October 3rd 09 04:28 PM
Easiest way to extract characters in a cell LEFT or RIGHT of a sym Training Goddess Excel Worksheet Functions 2 May 29th 07 09:05 PM
extract name when a date in another cell gets near cityfc Excel Worksheet Functions 5 November 10th 05 01:20 AM
extract name when a date in another cell gets near cityfc Excel Discussion (Misc queries) 1 November 9th 05 07:40 PM
Extract date from cell Eric Excel Worksheet Functions 3 November 4th 04 06:37 PM


All times are GMT +1. The time now is 04:28 PM.

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

About Us

"It's about Microsoft Excel"