The magnetic surface anisotropy in ultrathin films with a distribution of surface roughness is calculated with a magnetostatic model. The surface roughness can give the famous 1/t dependence of shape anisotropy for thick films; however, the anisotropy deviates from 1/t dependence for very thin films. It can be concluded that a rougher film results in a larger surface anisotropy. The calculated results are reasonably consistent with the experiment.< >