Excel97+referring to another worksheet in VBA

  csqwared 16:08 23 Jan 08
Locked

Hi

I'm working on a workbook trying to utilise my limited knowledge of Excel VBA and so far it's gone quite well. However, I'm now stuck. What I am trying to do is look at a cell in worksheet1 and compare it with a lot of cells in worksheet2 and if they are the same set certain parameters in worksheet1. My idea was to use a nested loop but for the life of me can't hit on the right syntax. I have a couple of reference books but just can't crack it. My code (in worksheet1) is:-

for g = 1 to 20
for a = 1 to 20
if cells(a,"a") = (this is the bit I can't get right) 'worksheet2'!.cells(g,"a") then...........

I've tried all sorts of variations for the last part, even recorded a macro to see how that did it with no success. Any help would be much appreciated.

Thanks

cc

  VoG II 18:48 23 Jan 08

If Sheets("Sheet1").Cells(a, "A").Value = Sheets("Sheet2").Cells(g, "A").Value Then

  csqwared 14:26 24 Jan 08

That works perfectly - thanks very much.

cc

This thread is now locked and can not be replied to.

Nintendo Switch review: Hands-on with the intuitive modular console and its disappointing games…

1995-2015: How technology has changed the world in 20 years

This abstract video touches on division in our technologic world

Best alternatives to iTunes for Mac | Best music players for macOS: Free your music from the…