Hi !

with a row header in Sheet2, could be easily achieved without a code just with an advanced filter & formulas.
Of course if really a code is needed just activating the Macro Recorder as a starter …

The other way like Sheet2 is actually : via a Dictionary object …