+ Reply to Thread
Results 1 to 20 of 20

Dependent Values in COLUMN 2 for COLUMN 1

  1. #1
    Registered User
    Join Date
    12-29-2015
    Location
    INDIA
    MS-Off Ver
    MS 2010
    Posts
    10

    Dependent Values in COLUMN 2 for COLUMN 1

    Hello Guys,


    I have two columns, where some values in column 2 would have values that are present in COLUMN 1. So I would like to list out dependent values for coulumn. Is there any way or any formula that would help me in achieving this?

    I have about 2.5 K records, so manual process is bit difficult. Also to mention COLUMN 2 might have blank values too, but it would contain values present in COLUMN1.

    Below is a sample of what is expected.

    Validation 11 Nov.jpg


    Regards,
    Harsha

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Dependent Values in COLUMN 2 for COLUMN 1

    Im sorry, Im not able to understand exactly what your requirements are? You say that column 2 will have values present in column 1 yet none of your examples match that. Its not therefore possible to decide what logic would be applied to column 2
    If someone has helped you then please add to their Reputation

  3. #3
    Registered User
    Join Date
    12-29-2015
    Location
    INDIA
    MS-Off Ver
    MS 2010
    Posts
    10

    Re: Dependent Values in COLUMN 2 for COLUMN 1

    Sorry I should have meant the column headers instead. Please could you refer the column B&C, where column 1 and Column 2 are marked up.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,396

    Re: Dependent Values in COLUMN 2 for COLUMN 1

    I'm sorry - I can't understand the relationship between the columns, either. Could you explain clearly what it is?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Dependent Values in COLUMN 2 for COLUMN 1

    Quote Originally Posted by harsha123 View Post
    Sorry I should have meant the column headers instead. Please could you refer the column B&C, where column 1 and Column 2 are marked up.
    I did, they still dont have any relevance to each other.

  6. #6
    Registered User
    Join Date
    12-29-2015
    Location
    INDIA
    MS-Off Ver
    MS 2010
    Posts
    10

    Re: Dependent Values in COLUMN 2 for COLUMN 1

    Take for example first row, where column 1 value is 1. So if we would check for value 1 in column2, it is present for values 4,5 , which needs to be marked up.

  7. #7
    Registered User
    Join Date
    12-29-2015
    Location
    INDIA
    MS-Off Ver
    MS 2010
    Posts
    10

    Re: Dependent Values in COLUMN 2 for COLUMN 1

    Take for example 1st row, where column 1 value is 1. So if we would check for value 1 in column2, it is present for values 4,5 , which needs to be marked up.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,396

    Re: Dependent Values in COLUMN 2 for COLUMN 1

    So you want a list of row numbers returning in column A?

  9. #9
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Dependent Values in COLUMN 2 for COLUMN 1

    Well that wasnt confusing at all!

    I think Ive worked out your requirement...

    Are you saying that you take the value in column B and search column C for that value, if its found then the row number is shown in column A? ie B3 contains "3" so you search column C for the number 3 and show the rows its found in column A ie column A becomes "8,9,10"

  10. #10
    Registered User
    Join Date
    12-29-2015
    Location
    INDIA
    MS-Off Ver
    MS 2010
    Posts
    10

    Re: Dependent Values in COLUMN 2 for COLUMN 1

    Yes. Thats is what I am looking for
    apologies for confusing.

  11. #11
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Dependent Values in COLUMN 2 for COLUMN 1

    Create the following UDF and then reference it in column A

    Please Login or Register  to view this content.
    ie in A1 use:
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    12-29-2015
    Location
    INDIA
    MS-Off Ver
    MS 2010
    Posts
    10

    Re: Dependent Values in COLUMN 2 for COLUMN 1

    Awesome Bro!!!!!! It worked like a charm.

  13. #13
    Registered User
    Join Date
    12-29-2015
    Location
    INDIA
    MS-Off Ver
    MS 2010
    Posts
    10

    Re: Dependent Values in COLUMN 2 for COLUMN 1

    it appears to work fine except for the last one in col B(value 14, it should be 1, but it is showing up as NO VALUE),

    Capture.PNG

  14. #14
    Registered User
    Join Date
    12-29-2015
    Location
    INDIA
    MS-Off Ver
    MS 2010
    Posts
    10

    Re: Dependent Values in COLUMN 2 for COLUMN 1

    Hi Guys,

    Any idea why the code isnt working for the last row?

    Regards,
    Harsha

  15. #15
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,396

    Re: Dependent Values in COLUMN 2 for COLUMN 1

    I have no idea about VBA, but could it be this?

    Please Login or Register  to view this content.
    What happens if you change the 2 to a 1?

  16. #16
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Dependent Values in COLUMN 2 for COLUMN 1

    Quote Originally Posted by AliGW View Post
    I have no idea about VBA, but could it be this?

    Please Login or Register  to view this content.
    What happens if you change the 2 to a 1?
    Yep, that would be the problem, the original image showed headers but it appears the file doesnt have them. As Ali says, change the 2 to a 1

  17. #17
    Registered User
    Join Date
    12-29-2015
    Location
    INDIA
    MS-Off Ver
    MS 2010
    Posts
    10

    Re: Dependent Values in COLUMN 2 for COLUMN 1

    Hi I just checked with my real case scenario, it is giving me the value of the row number, instead it should give me the value in that row number

  18. #18
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Dependent Values in COLUMN 2 for COLUMN 1

    Quote Originally Posted by harsha123 View Post
    Hi I just checked with my real case scenario, it is giving me the value of the row number, instead it should give me the value in that row number
    This is why its much easier to work with a sample workbook rather than a screenshot.

    change

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    12-29-2015
    Location
    INDIA
    MS-Off Ver
    MS 2010
    Posts
    10

    Re: Dependent Values in COLUMN 2 for COLUMN 1

    Function Find_Dependent(invalue)
    Dim xRow, LastRow As Integer
    Dim outval As String
    Dim sht As Worksheet
    Set sht = ActiveSheet
    LastRow = sht.Cells(sht.Rows.Count, "B").End(xlUp).Row
    For xRow = 2 To LastRow
    If (Cells(xRow, 3).Value = invalue) Then
    If (Len(outval) > 0) Then
    outval = outval & "," & Cells(xRow, 2).Value
    Else
    outval = Cells(xRow, 2).Value
    End If
    End If
    Next xRow
    Find_Dependent = outval
    End Function


    With the above code except for the first instance, it is working, for the first value I still get the row number.

  20. #20
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Dependent Values in COLUMN 2 for COLUMN 1

    what do you mean by the first value? is it the first in the list
    ie the 4 in 4,7,10 or the 2 in 2,3,4

+ 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. Replies: 4
    Last Post: 11-19-2014, 10:13 PM
  2. Replies: 2
    Last Post: 04-09-2014, 07:42 AM
  3. Replies: 2
    Last Post: 10-31-2013, 01:20 AM
  4. Replies: 0
    Last Post: 10-28-2013, 02:55 PM
  5. [SOLVED] Copy Data in column B to other columns dependent on Contents of column A
    By timbo1957 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-07-2013, 05:54 AM
  6. Replies: 1
    Last Post: 07-29-2013, 07:35 PM
  7. Change column reference to next column dependent on date
    By dinomike20 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-26-2011, 07:20 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