The fan black and blue are for fan and light. The ceiling red and black are from separate switches. Determine which color (red or black)is on the dimmer switch...this gets connected to the wire for the light. The other (red or black) gets connected to the wire for the fan.