Your question could be better phrased IMHO in two parts.
1) Did the revenues accruing to the owning state (metropole) come to more than the expense of running the colony, and defending it?
2) Did private investors from this metropole make money from it?
The obvious answer to (2) is yes, or they wouldn't bother. Though clearly some enterprises could be so badly run as to make a loss, collectively British firms made profits from British colonies (and other countries like Argentina) and ditto for German, French, Dutch ones.
(1) is trickier. It ought to be easy to make an estimate at the cost of administering a colony from British records (or those of any other Imperial power) then compare this total to direct revenues from that colony. However, what share of Imperial Defence expenditure should you allocate to it? Countering this, British firms profits from it are taxable as are the earnings and spending of their employees in the UK. There's also mu;yip;her effects and profits from things like shipping and sale of goods to the colonies. So overall economic profit could be positive even if the direct costs/revenue equation looks bad.
A jolly game for accountants but a bit boring for economists like me.
My gut feel is that few Sub-Saharan African colonies were financially profitable pre-WW!, except from looting as in the Belgian Congo. South Africa might be the exception and ones that could become economically profitable with investment include Kenya, Rhodesia and Ghana. I'm probably missing some French or German ones though from lack of knowledge of them.