Preheat oven to 375°F.Melt the butter in the microwave then pour it into the baking dish. In a large bowl, mix sour cream, cream of celery soup, milk, and black pepper. Add the hashbrowns and stir to mix well.
Layer half of the hash brown mixture into the baking dish pressing down to form an even layer. Sprinkle on half of the cubed ham and shredded cheese. Layer on the remaining hash brown mixture, ham, and cheese.
Drizzle melted butter over the crushed cornflakes and toss to combine. Sprinkle over the top of the potato mixture.Bake for 55-60 minutes until the top is golden and edges are bubbly. Let cool slightly before serving. Refrigerate leftovers for up to 5 days.