I have a Form with many Subs. Workbook has many sheets. When I start the Form when the active sheet is CodesSheet, using any of the For Each rCell in the code below work OK. When I start the code from a different sheet, code runs OK when using the second line -.Range("L2:L4125")-, but fails with the first one -.Range(Cells(2, 12), Cells(LastRowCodes, 12)).
Message is Run time error 1004 - Method Range of object _worksheet failed. But on debug, mouse over LastRowCodes shows the proper value (4125).
Anyone can spot the error?
For Each rCell In CodesSheet.Range(Cells(2, 12), Cells(LastRowCodes, 12)) '-->Error here, although LastRowCodes is correct
'For Each rCell In CodesSheet.Range("L2:L4125") '--> If using this instead of the above, no error
'Do Stuff
Next rCell