PDA

View Full Version : Getting Key value from last occurrence of another table



mjh4ck3r
06-02-2020, 01:12 AM
Hi,
Im fairly very new to VBA Scripting. i have a problem please find the below table
Output column is Comments



Name
Comments


Alert
A1


Phone
P2


Email
Not started




The comment column gets the value from the below table


Name
subname
value


Alert
A1

1​



Alert
A2

0​



Alert
A3

0​



Phone
P1

1​



Phone
P2

1​



Phone
P3

0​



Phone
P4

0​



Email
E1

0​



Email
E2

0​



Email
E3

0​






from first table it should look for the value in second table and check the value column for the last occurrence of 1 say in Alerts A1 is the last has 1 then A1 has to appear in the comment column in table 1, if all three are of alerts are done then its Comments is "Done".

Bob Phillips
06-02-2020, 03:48 AM
Don't understand that last paragraph at all. I cannot see why Alert is A2 but Phone is P2, and Email is Not Started. Why not A1, P1, and E1?

Fluff
06-02-2020, 04:45 AM
Cross posted https://www.mrexcel.com/board/threads/getting-key-value-from-last-occurrence-of-another-table.1135920/

mjh4ck3r
06-02-2020, 05:45 AM
Consider like this table 1 is the main table, for each value in table 1 names has multiple sub names in Table 2. the output is to get the Table 1 comment value from table 2 where the last occurrence of 1,
so for Alerts referencing to table 2 the 1 has stopped at A1
For Phone referencing to table 2 the 1 has stopped at P2, When p3 value in table 2 is changed to 1 the table 1 comment is changed to p3.
If all 5 are 1 then the comment should be Done.
Hope that clarifies.

Bob Phillips
06-02-2020, 07:11 AM
Why do you want to do it in VBA, why not a formula?

mjh4ck3r
06-02-2020, 08:34 AM
hmm, im open to that too.