ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Compare cells in different worksheets (https://www.excelbanter.com/excel-programming/396897-compare-cells-different-worksheets.html)

[email protected]

Compare cells in different worksheets
 
How would I compare cells values one from one sheet one from another.

I tried doing this
sub try()
For aa = 7 To 100 Step 8
For a = 2 To 12 Step 1
If Worksheets("Sheet1").Cells(2, aa) = Worksheets("Coating
Goals").Cells(2, a) Then Worksheets("Sheet1").Cells(2, aa).Font.Bold =
True
If Worksheets("Sheet1").Cells(2, aa) = Worksheets("Coating
Goals").Cells(2, a) Then Cells(2, aa).Font.Color = RGB(0, 0, 255)
Next
Next
End Sub

but this would not do check cell by cell. I want for "Sheet1". cells
(2,7) compare to "Coating Goal". Cells(2,2). Then check Sheet1". cells
(2,15) compare to "Coating Goal". Cells(2,3). so on and so on.


barnabel

Compare cells in different worksheets
 
try this instead:
sub try()
aa = 7
For a = 2 To 12 Step 1
If Worksheets("Sheet1").Cells(2, aa) = Worksheets("Coating
Goals").Cells(2, a) Then Worksheets("Sheet1").Cells(2, aa).Font.Bold =
True
If Worksheets("Sheet1").Cells(2, aa) = Worksheets("Coating
Goals").Cells(2, a) Then Cells(2, aa).Font.Color = RGB(0, 0, 255)
aa=aa+8
Next
End Sub


" wrote:

How would I compare cells values one from one sheet one from another.

I tried doing this
sub try()
For aa = 7 To 100 Step 8
For a = 2 To 12 Step 1
If Worksheets("Sheet1").Cells(2, aa) = Worksheets("Coating
Goals").Cells(2, a) Then Worksheets("Sheet1").Cells(2, aa).Font.Bold =
True
If Worksheets("Sheet1").Cells(2, aa) = Worksheets("Coating
Goals").Cells(2, a) Then Cells(2, aa).Font.Color = RGB(0, 0, 255)
Next
Next
End Sub

but this would not do check cell by cell. I want for "Sheet1". cells
(2,7) compare to "Coating Goal". Cells(2,2). Then check Sheet1". cells
(2,15) compare to "Coating Goal". Cells(2,3). so on and so on.




All times are GMT +1. The time now is 03:33 PM.

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