+ Reply to Thread
Results 1 to 9 of 9

Find the median of Column if Header contains specified text

  1. #1
    Registered User
    Join Date
    01-22-2024
    Location
    Singapore
    MS-Off Ver
    Microsoft 365 Version 2312
    Posts
    13

    Find the median of Column if Header contains specified text

    Hello, is there VBA code i can write to find the median of Column if Header contains specified text? For example, if the header contains "Test Time_X", it will be selected and the median of all columns selected will be calculated and input into D1. Thank you so much for your help!

    Book1 (2).xlsm
    Last edited by chyeenne; 01-28-2024 at 09:57 AM.

  2. #2
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Find the median of Column if Header contains specified text

    Please try in D1 and copy down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    01-22-2024
    Location
    Singapore
    MS-Off Ver
    Microsoft 365 Version 2312
    Posts
    13

    Re: Find the median of Column if Header contains specified text

    thank you so much for your reply! would there be a way that the formula wont read the entire header? eg Test Time_X VS Test Time_X_Oct. Thank you so much!

  4. #4
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Find the median of Column if Header contains specified text

    Please try in D1 and copy down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Find the median of Column if Header contains specified text

    I think that Hans is incorrect. His is returning the median of the first row, only:

    =LET(h,B$5:M$5,d,B$6:M$99,MEDIAN(INDEX(d,SEQUENCE(ROWS(d)),FILTER(SEQUENCE(,COLUMNS(h)),C1=LEFT(h,LEN(C1))))))
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  6. #6
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Find the median of Column if Header contains specified text

    I think Glenn is right.

    Another way to fix my mistake is to replace the INDEX function in my formula with the CHOOSECOLS function.
    Then the SEQUENCE(ROWS(d)) does not need to be added to the formula.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-22-2024
    Location
    Singapore
    MS-Off Ver
    Microsoft 365 Version 2312
    Posts
    13

    Re: Find the median of Column if Header contains specified text

    that worked wonderfully! thank you so much <3

  8. #8
    Registered User
    Join Date
    01-22-2024
    Location
    Singapore
    MS-Off Ver
    Microsoft 365 Version 2312
    Posts
    13

    Re: Find the median of Column if Header contains specified text

    thank you so much! <3

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Find the median of Column if Header contains specified text

    You're welcome. Thanks for letting us know that you got an answer.




    Please take a moment and consider clicking the "Add Reputation" button at the foot of any of the posts of anyone who helped you reach a solution here today.

    Finally, if that takes care of your original question, please click on "Thread Tools" from the menu link (just above the first post in the thread) and mark this thread as SOLVED.

+ 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. [SOLVED] Search through columns and find specific text and replace that text with header column
    By adamzee in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-09-2014, 11:59 PM
  2. Median Indirect: Find median in range and bring back adjacent cells
    By Keelin in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 06-27-2014, 08:31 AM
  3. [SOLVED] Find specific value in table and return header row and header column value
    By nelwan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-30-2013, 01:35 AM
  4. Replies: 1
    Last Post: 05-10-2013, 02:03 PM
  5. Replies: 2
    Last Post: 04-26-2013, 01:16 PM
  6. [SOLVED] Median Ifs, need to find median $ amount per deal for each year
    By xenomorph8472 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-13-2012, 02:01 PM
  7. [SOLVED] find the highest text value in a row, and return the corresponding column header
    By bumbling-idiot in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-09-2012, 07:09 AM

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