+ Reply to Thread
Results 1 to 8 of 8

Return header column text if value in row below

Hybrid View

  1. #1
    Registered User
    Join Date
    10-19-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    4

    Return header column text if value in row below

    Hi, 1st post ever so please accept my novice status..


    I have a spreadsheet as per below:
    sheet.PNG

    I'm trying to get a formula to calculate the value in column I automatically and have tried using the MATCH/INDEX combination but unsuccessfully.
    I2 shows the result I'm expecting.

    Please can someone help?

    thanks
    Adrian

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Return header column text if value in row below

    Suggest posting the workbook rather than an image.

  3. #3
    Registered User
    Join Date
    10-19-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Return header column text if value in row below

    forum sheet.xls

    thanks Martin - attached sample rows now.

    thanks
    Adrian

  4. #4
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Return header column text if value in row below

    So if there are multiple changes in a row, what do you want to appear in columns R and S?

  5. #5
    Registered User
    Join Date
    10-19-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Return header column text if value in row below

    nothing required really as those are handled via a different exception process
    thanks Adrian

  6. #6
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Return header column text if value in row below

    Might be easiest to do this with a user defined function.

    Function GetChangedHeader(MyRange1 As Range, MyRange2 As Range, MyRange3 As Range, MyRange4 As Range, MyRange5 As Range, MyRange6 As Range, MyRange7 As Range) As String
    If MyRange1 <> "" Then
        GetChangedHeader = Cells(1, MyRange1.Column)
        Exit Function
    ElseIf MyRange2 <> "" Then
        GetChangedHeader = Cells(1, MyRange2.Column)
        Exit Function
    ElseIf MyRange3 <> "" Then
        GetChangedHeader = Cells(1, MyRange3.Column)
        Exit Function
    ElseIf MyRange4 <> "" Then
        GetChangedHeader = Cells(1, MyRange4.Column)
        Exit Function
    ElseIf MyRange5 <> "" Then
        GetChangedHeader = Cells(1, MyRange5.Column)
        Exit Function
    ElseIf MyRange6 <> "" Then
        GetChangedHeader = Cells(1, MyRange6.Column)
        Exit Function
    ElseIf MyRange7 <> "" Then
        GetChangedHeader = Cells(1, MyRange7.Column)
        Exit Function
    End If
    End Function
    Open the VBA editor by hitting Alt F11.
    Insert a new module with Insert - Module
    Paste in the above function
    Go back to the sheet by hitting Alt F11.

    In a suitable cell, enter =GetChangedHeader(C2,E2,G2,I2,K2,M2,P2)

    Remember to save the workbook as a macro enabled workbook .xlsm

  7. #7
    Registered User
    Join Date
    10-19-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Return header column text if value in row below

    great - job done!

  8. #8
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Return header column text if value in row below

    @ Adrian W

    Welcome to the forum.

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ 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