+ Reply to Thread
Results 1 to 4 of 4

Select first and last occurence of a word

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Select first and last occurence of a word

    Hello everybody
    I have these values in range("A1:A10")
    A
    A
    A
    A
    B
    B
    B
    A
    A
    A
    I used the following line to select the first occurence of "A"
    Please Login or Register  to view this content.
    And used this line to select the last occurence of "A"
    Please Login or Register  to view this content.
    As for the line of the first occurence the code selects A2 not A1

    How can make the code select A1 instead of A2?

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,650

    Re: Select first and last occurence of a word

    make sure you give a good starting point for search. by default it is a first cell of searched range, so if the direction is xlprevious it works fine, but if it is xlnext (default one) it starts to search under the first cell. In typical situations it is fine, because there is often a header in a first cell.
    But in situation described :
    A
    A
    A...

    use last cell of searched range as starting point.

    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Select first and last occurence of a word

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Select first and last occurence of a word

    Thanks a lot for this quick help
    You are very helful

+ 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. Count Occurence of Word and return it to cell in another sheet
    By niran1706 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-13-2013, 06:10 AM
  2. [SOLVED] Formula to count occurence of each word in a column
    By minotour in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-25-2013, 08:57 AM
  3. Need a Macro to Cut String from the second occurence of a word, and paste into the next ce
    By loserianasia in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-03-2013, 03:38 PM
  4. Replies: 1
    Last Post: 01-21-2013, 01:21 PM
  5. [SOLVED] I want to count rows between the occurence of one word.
    By SM in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-07-2005, 04:40 PM

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