Let's suppose:
In sheet1 of the Excel book I have this table: and In sheet2 of the Excel book I have this other table:
The problem that I want to solve by VBA macro is that if I write any name in cell A2 of the "Patients" table, and whose name is in the set of cells (A2:A4) of the "Age Group" table, then the macro automatically fills in cells B2 and C2 of this table, with the values that correspond to the specific name written there.
Cheers!
Let's see
In sheet1, which I have called Patients, you paste this code (What it does is show a message that cell B6 has been changed if it changes its value and execute the ExtractData function)
You create a module, and paste this other code (What it does is store the name entered in cell B6 of Sheet1 in a variable. Then it executes a loop from cell B5 comparing the contents of the cells that have some data and evaluating that match the text with the name of Sheet1.
If it matches, it copies the contents of the cells on the right, years and weight, and pastes them into the corresponding cells on Sheet1