BobBridges
Active Member
I'm updating a worksheet function for a client, and I've run into a problem. The old version of the function looked for a particular section in the worksheet and extracted a value from it. He wants the new version to search not just the one section but that and the next one too, so I thought I'd "improve" the logic by using a class method that maps the worksheet, section by section, and pull the two sections I want with less trouble.
Instead I'm having trouble. When the mapping method invokes the SpecialCells(xlCellTypeLastCell) method, it returns Cell(1, 1); it should be the last used cell on the worksheet, for example Cell(25, 8). The next statement tries for an Offset value of that cell, and it triggers an error ("Application-defined or object-defined error").
When I call this logic in a Sub, it works fine. Is there something about the SpecialCells method that prevents it from working properly inside a worksheet function? If so, I don't recall knowing it before.
Instead I'm having trouble. When the mapping method invokes the SpecialCells(xlCellTypeLastCell) method, it returns Cell(1, 1); it should be the last used cell on the worksheet, for example Cell(25, 8). The next statement tries for an Offset value of that cell, and it triggers an error ("Application-defined or object-defined error").
When I call this logic in a Sub, it works fine. Is there something about the SpecialCells method that prevents it from working properly inside a worksheet function? If so, I don't recall knowing it before.