+ Reply to Thread
Results 1 to 4 of 4

Searching strings in Excel sheet

  1. #1
    Registered User
    Join Date
    07-04-2008
    Location
    Melbourne
    Posts
    2

    Smile Searching strings in Excel sheet

    Hello all
    I am wondering if anyone can help me out with a formula or a macro to do the following:
    I have an excel sheet with a list of characters in each cell of the column. is there any way to select and highlight certain characters based on their position.

    For example
    ABCDEFGH
    ADDDDDEB

    Can we somehow highlight all cells which have 'A' in the first position and 'G' in the penultimate position? So in theory it should only highlight the first cell.

    What sort of commands should I be looking at to do functions like that so I can devise more rules like perhaps 'A' in position 1 and 'D' in position 2 and/or 'E' in position 3 etc
    Any direction with some explanation would be greatly appreciated and I am happy to troll through help files to figure out finer details.

    Thanks heaps!!!

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Searching strings in Excel sheet

    It sounds as though you want to use Conditional Formatting with a Formula Based approach, however, depending on the XL version you are using you are limited in how many test you can run - pre XL2007 you are limited to 3 tests (+ standard format), if you have more than that and are running a pre XL07 version you will need to use VBA.

    A sample Conditional Format formula test based on your example would be as follows:

    =AND(LEFT(A1,1)="A",MID(A1,LEN(A1)-1,1)="G")
    format set accordingly

    (where A1 holds first string)

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Searching strings in Excel sheet

    you could be a bit more dynamic in attached sheet put the 2 letters you want to find and in what position then cells will be highlighted
    conditional format is
    =AND(CHOOSE($D$2,MID(A1,1,1),MID(A1,2,1),MID(A1,3,1),MID(A1,4,1),MID(A1,5,1),MID(A1,6,1),MID(A1,7,1),MID(A1,8,1))=$D$1,CHOOSE($D$4,MID(A1,1,1),MID(A1,2,1),MID(A1,3,1),MID(A1,4,1),MID(A1,5,1),MID(A1,6,1),MID(A1,7,1),MID(A1,8,1))=$D$3)
    Attached Files Attached Files
    Last edited by martindwilson; 04-28-2009 at 05:57 AM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Registered User
    Join Date
    07-04-2008
    Location
    Melbourne
    Posts
    2

    Re: Searching strings in Excel sheet

    Dear Martin and DonkeyOte
    Thanks heaps for your suggestions I only recently got to try them and they work treat. Especially Martin's excel sheet is amazing!
    Thanks very much guys and yes I do sincerely apologise for not replying in a very timely fashion!

    now looking forward to analysing the data!!!

    Have a great weekend!


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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