Not quite shure in what degree you want them upgraded.. if you want to replace the button for training the units, and maby replace all archers with rangers.. i would do something like this..
Variables
LeakUnitGroup (Unit Group)
Trigger 1
Initialization
Events
Map initialization
Conditions Actions
Advanced - Initialize advanced triggers*
Player - Make Rifleman Unavailable for training/construction by Player 1 (Red)
Trigger 2
Research Riflemen
Events
Unit - A unit enters (Entire map)
Conditions
(Unit-type of (Triggering unit)) Equal to Research Rifleman
Actions
Unit - Remove (Triggering unit) from the game
Set LeakUnitGroup = (Units owned by (Owner of (Triggering unit)) matching ((Unit-type of (Matching unit)) Equal to Archer))
Unit Group - Pick every unit in LeakUnitGroup and do (Actions)
Loop - Actions {
Unit - Replace (Picked unit) with a Rifleman using The old unit's relative life and mana
}
Player - Make Research Rifleman Unavailable for training/construction by (Owner of (Triggering unit))
Player - Make Archer Unavailable for training/construction by (Owner of (Triggering unit))
Player - Make Rifleman Available for training/construction by (Owner of (Triggering unit))
Advanced - Only for (Owner of (Triggering unit)) play KnightResearchComplete1 <gen>*
*This action is a plugin by world editor unlimited.. can be downloaded here:
http://www.wc3campaigns.net/tools/weu/
Its a usefull tool to add some trigger funcions, remove limmits and such.. there is a list of benefits on the site.