So, sometimes when I try to execute this command, it gives me an error. The problem is that it is very inconsistent. In certain cases, it works and in others, it just doesn't.
This is the line from getCellVal function. cellName is a string and s is an integer.
getCellVal = Sheets(s).Range(cellName).Value
This time it is giving me: Run-time error '438': Object doesn't support this property or method
This line actually worked without problems moments ago. I added some other functions that use it and now it's not working anymore.
Any ideas about why?
cellNameis aNamed Rangewith workbook scope, then remove theSheets(s).from the right side.Rangecalls implicitly refer to the active worksheet (unless you're in a worksheet's code-behind) - that would actually make things worse ;-)Defined Namewith Workbook Scope, which is what I wrote.Workbook.Namescollection for workbook-scoped names, and via theWorksheet.Namescollection for worksheet-scoped names.Range's behavior is broken and unintuitive.