Your code, as it is, isn't actually moving anything. You're assigning a Vector3 and modifying it's Y value, but you're not altering the Y value of the GameObject's transform. Having said that, you can't simply say:
transform.position.y = y;
Because Unity won't let you. Best way to do this for a beginner would be:
int y = Random.Range(140, 155);
transform.position = new Vector3(0, y, 0);
That code will move the object to which this script is attached to a random Y position between 140 and 155, with X and Z both at 0. If you want the object to stay where it is in the world, but only move on the Y-axis, use:
transform.position = new Vector3(transform.position.x, y, transform.position.z);
Instead. This will move the object to which this script is attached to a random Y value without altering it's X and Z values.