Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hii all
I am trying to write a macro to compare first 50 values of, say column A of sheet 1 and column B of sheet 2. I want the macro to highlight only those cells of column A that equal to sheet 2 column B values. thanks |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
try this macro. To use, highlight cells in column A on Sheet1. the macro
will compare these same rows in Sheet2 in column B Sub CompareSh1Sh2() Const FirstSheet = "Sheet1" Const SecondSheet = "Sheet2" Const FirstSheetCol = 1 Const SecondSheetCol = 2 Worksheets(FirstSheet).Activate Lastrow = ActiveCell.End(xlDown).Row Set MyRange = Range(Cells(ActiveCell.Row, FirstSheetCol), _ Cells(Lastrow, FirstSheetCol)) For Each Cell In MyRange SecondCell = Worksheets(SecondSheet). _ Cells(Cell.Row, SecondSheetCol) If (Cell = SecondCell) Then Cell.Interior.ColorIndex = 4 Else Cell.Interior.ColorIndex = xlNone End If Next Cell End Sub "sharmashanu" wrote: Hii all I am trying to write a macro to compare first 50 values of, say column A of sheet 1 and column B of sheet 2. I want the macro to highlight only those cells of column A that equal to sheet 2 column B values. thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Add sheets using macro | Excel Worksheet Functions | |||
macro for new sheets | Excel Worksheet Functions | |||
macro/new sheets | Excel Discussion (Misc queries) | |||
macro to hide sheets | Excel Discussion (Misc queries) | |||
Macro for moving sheets | Excel Discussion (Misc queries) |