ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Looping through sheets and comparing data (https://www.excelbanter.com/excel-programming/432175-looping-through-sheets-comparing-data.html)

TomK76

Looping through sheets and comparing data
 
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!

joel

Looping through sheets and comparing data
 
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


"TomK76" wrote:

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!



All times are GMT +1. The time now is 11:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com