Effect of grain size and crystalline orientation on magnetic switching