If you are trying to do the same as before then the initial 'formula' looks like this:
="XXXIF(Sheet" & G3 & "!$B$1<=5,Sheet" & G3 & "!$B$2,Sheet" & G3 &"!$B$3)"
The formula you posted has an extra ' in it,
or a missing '
depends on how you look at it.
The worksheet name can be used without single quotes if there are no spaces in the name, so =Sheet1!B1 is OK
but with a space it has to be ='Sheet 1'!B1