hiding row if the cell is found in a differeent column

I

Ivan

Hi,

sheet1 data
2 a
5 b
12 c

sheet2 data

2
3
4


I would like to write a macro as follows:

if I find the value in column a of sheet 1 IN column a in sheet 2, hide that
column in sheet one (loop for the range of cells).

I have the following so far: I am clearly having trouble figuring out the
find portion.
Thanks.


Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

On Error GoTo Exits:

If Selection.Rows.Count > 1 Then
Set Rng = Selection
Else
Set Rng = Range(Rows(1),
Rows(ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row()))
End If
RwCnt = 0
For Rw = Rng.Rows.Count To 1 Step -1
If Rng.Rows(Rw).entirerow.find( lookin: sheets("Sheet1"))= true Then
Rng.Rows(Rw).EntireRow.Hidden = True
RwCnt = RwCnt + 1
End If
Next Rw

Exits:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

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