+ Reply to Thread
Results 1 to 4 of 4

Horizontal Search

  1. #1
    Registered User
    Join Date
    04-06-2013
    Location
    USA
    MS-Off Ver
    MS Office Professional Plus 2019
    Posts
    77

    Horizontal Search

    Hi . . .

    I am having trouble trying to find the right formula to search each horizontal row for the number "4".

    I need the formula to return the Column that the "4" is in or the Columns as sometimes there is more than one "4" in the row.

    Column A in the attached sheet is where the formula needs to go and we search the columns C to AH for each row.

    Thanks

    Nick
    Attached Files Attached Files

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Horizontal Search

    For multiple results in a single cell you'll need some form of VBA to do this.

    Select any sheet tab
    Right click>View Code
    Open the Project Explorer (if it's not already open): CTRL R
    In the Project Explorer pane on the left, locate your file name. It'll appear like this: VBAProject(SearchTest.xlsx)
    Select the file name then right click
    Select Insert>Module
    Copy the code below and paste it into the window that opens:

    Please Login or Register  to view this content.
    Go back to Excel: ALT Q

    Now, enter this array formula** in A2 and copy down to A139:

    =SUBSTITUTE(TRIM(aconcat(IF(C2:AH2=4," "&C$1:AH$1,"")))," ",", ")

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    Here's your file with this applied:

    SearchTest.xlsm

    Since the file now contains VBA code it has to be saved as a macro enabled file in the file format *.xlsm.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    04-06-2013
    Location
    USA
    MS-Off Ver
    MS Office Professional Plus 2019
    Posts
    77

    Re: Horizontal Search

    Works like a charm . . .

    thank you so much, you have save me a lot of time

    Cheers

    Nic

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Horizontal Search

    You're welcome. Thanks for the feedback!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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