I'm working on a function that will compare each cell in a range to the cell before it, and return a 0 if they are equal and a 1 if they are different.

Know how to make the loop to do the comparison, but I am having an issue with using cells on other worksheets. In subroutines, I can use Worksheets("Worksheet Name").Select to change worksheets and then pull data. When I write a function, I cannot change worksheets (even Worksheets("Sheet Name").Cells() doesn't work.)

What's the trick here? What's the command to change worksheets so I can pull cell data from other sheets for a user-defined function, or is that not possible?