Referencing cells on non-active sheets

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to reference a cell on a non-active sheet, without first
activating or selecting that sheet?

I'm writing code to compare 2 near-identical tables and copy the differences
into a summary table.

I'm finding that jumping back and forth between the two tables takes quite a
lot of time (when it's done for hundred's of rows with ~20 columns).

Is there a way for me to reference the cells on each sheet without
activating them? The cells to be compared are in identical places, just on
different sheets.

For example:

If Worksheet(1).Range(R,C).Value <> Worksheet(2).Range(R,C).Value Then ...

Is this possible?

Thanks,
KellyB
 
If Worksheet(1).Cells(R,C).Value <> Worksheet(2).Cells(R,C).Value Then

You almost had it.
 
That does work. I was using the Range(R,C) property before and it wasn't
working. Not sure why. The Cells property does work.

Any info on why this is?
Thank.
 
Range will only accept multiple arguments if they are ranges or can be seen
as ranges.

Range("A1").Address

or
Range("A1","B2").Address

Range doesn't accept row/column as separate arguments. That is why we have
CELL.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top