+ Reply to Thread
Results 1 to 3 of 3

find the character position in a string of the last occurrence of a nominated character

  1. #1
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    find the character position in a string of the last occurrence of a nominated character

    Hi All,

    I have a VBA string variable (working_data) that contains a mixture of characters and numbers logically split into different "fields" by a "@" character.

    My question is, is there a way for VBA to do the hard work of finding the character position of the last "@" in working_data rather than me having to loop backwards until I find "@"

    Apologies if this is a simple feature that is beyond my current knowledge level

    Jmac

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: find the character position in a string of the last occurrence of a nominated characte

    Use the InStrRev function to find the position of the last occurrence. It searches from right to left, but the position it returns is still numbered from the left.

    LastAtPos = InStrRev(working_data, "@")
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: find the character position in a string of the last occurrence of a nominated characte

    exactly what I needed, many thanks

    Jmac

+ 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: 7
    Last Post: 08-31-2013, 12:30 PM
  2. Find last repeated character position from a text string
    By krjoshi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-17-2011, 02:14 PM
  3. Replies: 2
    Last Post: 02-22-2007, 12:42 PM
  4. Find Character Position in String
    By SportsDave in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-21-2006, 04:49 PM
  5. Function to return Character Position of Xth character within a string
    By Andibevan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-09-2005, 11:05 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