Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi Sulie Supposing the numbers identify the students and supposing that they ar in column G both on sheet1 and sheet2 the macro below could solve you problem: Sub DeleteRowsOnSheet2() Dim lRow As Long, lMaxRow As Long Dim vRow As Variant Dim sht1 As Worksheet, sht2 As Worksheet Set sht1 = Worksheets(1) Set sht2 = Worksheets(2) ' make things run faster Application.ScreenUpdating = False ' thx to david mcritchie <g lMaxRow = sht1.Cells(Rows.Count, 7).End(xlUp).Row For lRow = 1 To lMaxRow ' if we have a number on this row in column G If Not IsEmpty(sht1.Cells(lRow, 7)) Then ' try to find it on sheet 2 in column G vRow = Application.Match(sht1.Cells(lRow, 7), sht2.Columns(7) 0) If Not IsError(vRow) Then ' the number is there, so delete the row sht2.Rows(vRow).Delete End If End If Next lRow MsgBox "Done!" Set sht1 = Nothing Set sht2 = Nothing End Sub With kind regards, Ton Teun -- Ton ----------------------------------------------------------------------- TonT's Profile: http://www.officehelp.in/member.php?userid=4 View this thread: http://www.officehelp.in/showthread.php?t=66124 Visit - http://www.officehelp.in/archive/index.php | http://www.officehelp.in/index/index.ph |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
find and delete rows macro | Excel Discussion (Misc queries) | |||
find text and delete rows. | Excel Discussion (Misc queries) | |||
Find and delete all other rows | Excel Discussion (Misc queries) | |||
Find according to sheet 2, Delete rows in COL A | Excel Programming | |||
Find item and delete rows | Excel Programming |