How can this code be modified to show the result on more sheets based on a condition ?

  • Hello,


    I need your assistance with a vba code. I don't know how to change it to do what I need unfortunately.

    To make things easier, I will upload my excel file here.


    Please check the code below:


    My excel file has at the moment 9 sheets but it will have more sheets similar to the sheets 6 - sheet 9.

    What I want is to make the vba code that's added into Sheet 3, to show the result also in Sheet 6-sheet x, (where x is the last sheet I will add), based on 1 condition.


    Example:


    If WS3: B14 = 13396, and H14 = whatever,

    Then show the result of the vba code in WS2, G329 ( 329 being the matching row of the 13396 code inside WS2.)


    But also, if I change the B14 with B14 = 12375, and H14 = whatever,

    Then show the result of the vba code in WS2, G98 ( 98 being the matching row of the 12375 code inside WS2).


    What I said above is what the code does now. I need it to also do this:


    If WS3: B14 = 13396, and H14 = whatever, and G9=Sheet6 (It won't actually say sheet 6, but it will be a data validation list)

    Then show the result of the vba code in WS2, G329 ( 329 being the matching row of the 13396 code inside WS2.)

    And also show the result of the vba code in WS6, F6 (6 being the matching row of the 13396 code inside WS6)


    If WS3: B14 = 13396, and H14 = whatever, and G9=Sheet8

    Then show the result of the vba code in WS2, G329 ( 329 being the matching row of the 13396 code inside WS2.)

    And also show the result of the vba code in WS8, F6 (6 being the matching row of the 13396 code inside WS8)


    If G9 = empty, then the vba code should do just the first part where the result is shown only in WS2.


    I want to mention that the value of 13396 inside Sheet6 to Sheet x, won't be always at the same row.

    1336 can be in Sheet 6 in row 6, but in Sheet 15 can be in row 25. The fact that both Sheet 6 and Sheet 8 has the code 1336 in B6 is a coincidence.

    Basically, I want the code to show the results in ws2 everytime, but also to match the row in the other worksheets and based on the condition that G9=whatever, to show the result in the specified sheet too, at the correct row.


    I think that it is important to say, I don't need the hidden columns part for the other sheets. Just for WS2 as it is now, but if it's easier to let it there, then let it there.


    Any help with this issue will be much appreciated.

    Thank you






    This is what I need the code to do.

  • Hi Victor,


    Try this code in the code for the sheet:



    And this code in a module:


    Change your drop down in G9 to reflect the sheet names not their references.


    Let me know how it goes.

  • Hello Justin,

    I've tried your new code. It works great.

    As you know, I've sent you in chat the manual version of it that I managed to make, but thank you so much for this answer which is the automated version.

    You are the man.