に代（か）わって is an expression that will only appear with nouns, conveying that (B) is doing something ‘in place of (A)’, or ‘on behalf of (A)’. This is a combination of the 格助詞（かくじょし） (case marking particle) に
, the う - Verb 代（か）わる ‘to substitute’, and the 接続助詞（せつぞくじょし） (conjunction particle) て.
It has been decided that I am going to go shopping in place of my sister.
I will be attending the meeting in place of her.
に代わり may also be used, as this is the formal conjunctive. Also known as the 連用形（れんようけい）.
In place of Tanaka-san, today, I am going to be in charge of you guys.
All around the world, fax has been replaced by email as the main form of communication, but there still are places in Japan that only use fax.
In this construction, に
is acting as a location marker, rather than specifically meaning ‘for (A)’. What this means is that に代（か）わる is the act of removing (A) from its place, and exchanging it for (B). This is why に代（か）わって may also be used in the meaning of ‘to succeed’, or ‘to replace’, as switching (A) to (B) may be permanent.
Today, I will take charge of the meeting in place of the CEO.
In place of my father, I greeted everyone.