Expand variables in a sed substitution on Bash

sed -i.bak ‘s/string_to_replace/’$variablename’/g’ filename

The string to be replaced is, as usual, unquoted. However the variable to be used is single quoted. Contrary to normal Bash practise, the single quote expands instead of being literal.