The following formulas work when used in Conditional Formatting:
=AND(FIND(B1,"h"),LEN(G1)=2)
=AND(FIND(B1,"w"),LEN(G1)=3)
=OR(AND(EXACT(B1,"h"),LEN(G1)=3),AND(EXACT(B1,"w"),LEN(G1)=2))
but this one does not
=OR(AND(FIND(B1,"h"),LEN(G1)=3),AND(FIND(B1,"w"),LEN(G1)=2))
The only difference is the use of FIND instead of EXACT.
RFM
Bookmarks