How to dual power PIC18F4550?
The problem is that you used an NPN transistor instead of the PNP transistor specified in the schematic. Replacing the transistor with a PNP device should get things working. A common PNP transistor that I can remember off the top of my head is the 2N3906, but there are probably other devices better suited for this task.

The basic premise of the circuit is that when the circuit is not self powered, VSELF is floating or at 0 V. This causes a current to be pulled from VBUS through the emitter and the base, and through the two resistors to ground. To estimate what the sum of these resistors should be, we can make some assumptions about the circuit that are somewhat pessimistic. We will say that VBUS = 4.5 V and that we will be drawing 100 mA, which is one of the power levels of USB. We will use the 2N3906 datasheet for some of these numbers.



\$V_{BE} = 0.8 V\mbox{ to }0.9V \mbox{ at }\beta=10\$ depending on temperature (see figure above)

\$I_B=\dfrac{I_C}{\beta}=\dfrac{100 mA}{10} = 10mA\$

\$V_B=V_{BUS}-V_{BE}=4.5V - 0.9V=3.6V\$

\$R_1+R_2=\dfrac{V_B}{I_B}=\dfrac{3.6V}{10mA}=360\Omega\$

Without knowing what else is connected to VSELF or how VSELF behaves when it is not powering the device, I would be inclined to recommend the bottom resistor be 330 Ohms, and the top resistor be 33 Ohms, or omitting the top resistor completely (and having the bottom resistor equal to 360 Ohms).