+ Reply to Thread
Results 1 to 5 of 5

Function to grab info in middle of string

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-19-2004
    Posts
    252

    Function to grab info in middle of string

    I want to put together a function that grabs the 23.85 out of a string like this
    $23.85@74%11-14-07
    or the 353.67 out of a string like this
    $353.67@42.9%11-14-07
    but haven't the slightest idea how to program the logic that would grab that out of a string. Can someone give me some direction?

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    If the data is consistant... you can use a formula such as:

    =MID(A1,2,FIND("@",A1)-2)+0 to extract that number
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573
    =mid(a1,2,find("@",a1,1)-2)

  4. #4
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    Hi

    If it is always between the $ and the @ you can use these as markers to identify the string element you want to remove. The following assumes the $ is always the first $ in the string, and likewise with the @:

    Dim strComplete As String
    strComplete = "$23.85@74%11-14-07"
    
    Msgbox Split(Split(strComplete,"$")(1),"@")(0)
    Richard

  5. #5
    Forum Contributor
    Join Date
    09-19-2004
    Posts
    252
    Thanks everyone for your help but I was looking for code for a function.

    Richard,
    You hit the nail on the head, that works perfectly thanks. Here are my results
    Public Function REF(Cell As String) As String
    If InStr(Cell, "@") <> 0 Then
    REF = Split(Split(Cell, "$")(1), "@")(0)
    Else
    REF = ""
    End If
    End Function

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 9
    Last Post: 06-06-2009, 12:09 PM
  2. Excel Function Output not updating
    By aj_uk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-16-2008, 04:37 AM
  3. how2 export a VERY long string out of Excel
    By jimredfield in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-22-2008, 06:18 PM
  4. Emailing from notes: pasting values into mail body
    By matpj in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-18-2008, 11:14 AM
  5. Link together different cells in specific order?
    By Sandman4432 in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 01-03-2008, 05:01 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1