The official maximum length for Cat5e run is 100 meters. That is from computer to computer or computer to switch. Hubs do not add to the length, so if there is a hub between computers, the total length must be less than or equal to 100 meters.
If you're having problems with a shorter run, it is most likely a flaky cable. Make sure it is wired correctly and that the wires reach all the way to the end of the connector. It can be hard to tell with some connectors. If you hold the connector with one hand and tug the cable gently with the other there should be no movement of the outer sheath in the connector. Also, if it is a crimped connector, the sheathing should be inside the connector and crimped by the plastic. If you have the patience and a crimper, just cut both ends off and put two new ends on. It may take a few tries and a few inches of cable to get it right, but it's cheaper than buying new cables.
There are some pretty good instructions on making a patch cable
here.