We introduce a hardness formula for the multicomponent covalent and ionic solid solutions. This expression is tested on nitride spinel materials A(3)N(4) (A=C,Si,Ge) and applied to titanium nitrogen carbide (TiN(1-x)C(x) with 0 <= x <= 1), off-stoichiometric transition-metal nitride (TiN(1-x) and VN(1-x) with x <= 0.25), and B-doped semiconductors (C(1-x)B(x), Si(1-x)B(x), and Ge(1-x)B(x) with x <= 0.1). In all cases, the theoretical hardness is in good agreement with experiments.