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: 29
Default Macro to delete specific rows

This works fine:

Sub DelDups_TwoLists()
Dim iListCount As Integer
Dim iCtr As Integer
Application.ScreenUpdating = False
iListCount = Sheets("sheet1").Range("A1:A100").Rows.Count
For Each x In Sheets("Sheet2").Range("A1:A100")
For iCtr = 1 To iListCount
If x.Value = Sheets("Sheet1").Cells(iCtr, 1).Value Then
Sheets("Sheet1").Cells(iCtr, 1).Delete xlShiftUp
iCtr = iCtr + 1
End If
Next iCtr
Next
Application.ScreenUpdating = True
End Sub


"Martin Fishlock" schreef in bericht
...
Hi Gert-Jan,

Try this one:

Option Explicit

Sub delrows()

Dim lData As Long
Dim ans As Variant
On Error Resume Next
For lData = 40 To 1 Step -1
ans = -1
ans = Application.WorksheetFunction.Match( _
Worksheets("sheet1").wsData.Cells(lData, 1), _
Worksheets("sheet2").Range("A1:A10"), 0)
If ans < -1 Then wsData.Rows(lData).Delete
Next lData
End Sub

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Gert-Jan" wrote:

Hi,

In sheet1, range A1:P40 I have values. In the range A1:A40 there are ID
numbers. In sheet2, range (A1:A10) there are also ID numbers, wich might
correspondend to the range A1:A40 in Sheet1. I want a macro that deletes
the
rows in sheet1 with the ID-numbers that are in sheet2.

Any help would be appriciated.

Beste regards, Gert-Jan





 
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
Macro to delete rows containing specific data Slohcin New Users to Excel 2 December 20th 06 11:52 AM
Macro to keep 15 specific records and delete 1000 other rows. Sam Excel Programming 6 October 23rd 06 12:04 AM
Macro to delete specific rows above selected cell [email protected] Excel Programming 3 August 25th 06 04:14 PM
Macro to search across multiple columns and delete rows not containing specific value JenIT Excel Programming 5 August 16th 06 06:59 PM
Macro to delete specific rows Steve Excel Programming 12 October 1st 04 11:50 PM


All times are GMT +1. The time now is 11:14 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"