My Excel macro has Dim ws As Worksheet followed by ws = ThisWorkbook.Worksheets("Data"), and that line fails with run-time error 91. Yet x = ws.Range("A1") works without any special keyword once I fix the first line with Set. Later in the same macro, Set hit = ws.Range("A:A").Find("TOTAL") followed by r = hit.Row gives error 91 again on some sheets.
What is the rule for Set, and why does the second case fail only sometimes?




