LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default find and delete rows


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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
find and delete rows macro clayton ledford Excel Discussion (Misc queries) 4 January 20th 09 03:34 PM
find text and delete rows. John Excel Discussion (Misc queries) 5 December 12th 07 04:25 AM
Find and delete all other rows Murray Excel Discussion (Misc queries) 1 August 7th 07 02:54 AM
Find according to sheet 2, Delete rows in COL A Rubix³ Excel Programming 3 June 24th 04 12:12 AM
Find item and delete rows Joseph[_28_] Excel Programming 1 April 20th 04 06:55 PM


All times are GMT +1. The time now is 10:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"