Looping through sheets and comparing data

T

TomK76

Hi,

I am trying to get a macro that loops through the worksheets in the workbook
and compares the values in the same cells in each...in other words, it
compares the value in G3 of Sheet 2 with the value cell G3 in all the other
sheets. When a match is found, I need the value in O3 from the matching sheet
copied into O3 on the original worksheet (this macro would only be run from
one worksheet, either by clicking a button or by running automatically when a
value is entered into a certain cell).

Thanks!
 
J

Joel

I think this is what you want. Not sure which direction yo uwant to copy the
O3 value. I think you want to write to Sheet2.

Sub FixO3()

MatchValue = Sheets("Sheet2").Range("G3")

for each sht in sheets
if sht.name <> "Sheet2" then
Sheets("Sheet2").Range("O3") =sht.Range("O3")
end if
next sht

end sub
 

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

Top