Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Delete rows if not as range

I need to delete rows if sheet1 Column F not equal to Sheet3 G5:G10

I tried below code, but it works very very slow.. Actually there are around
25000+ records..

sub deleterows()
Set MySheet = Sheets("Sheet1")
LR = MySheet.Cells(Rows.Count,"F").End(xlup).Row
For i = LR to 2 Step -1
With Sheets("Sheet3")
If WorksheetFunction.Countif(.Range("G5:G10"),MySheet .Cells(i,"F"))0 Then
MySheet.Rows(i).EntireRow.Delete
End If
End With
Next i
End Sub


Any better one..?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Delete rows if not as range

Dear Kashya, try replacing the CountIF function with Match.

If this post helps click Yes
---------------
Jacob Skaria


"Kashyap" wrote:

I need to delete rows if sheet1 Column F not equal to Sheet3 G5:G10

I tried below code, but it works very very slow.. Actually there are around
25000+ records..

sub deleterows()
Set MySheet = Sheets("Sheet1")
LR = MySheet.Cells(Rows.Count,"F").End(xlup).Row
For i = LR to 2 Step -1
With Sheets("Sheet3")
If WorksheetFunction.Countif(.Range("G5:G10"),MySheet .Cells(i,"F"))0 Then
MySheet.Rows(i).EntireRow.Delete
End If
End With
Next i
End Sub


Any better one..?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Delete rows if not as range

Hi, would you please help me out with the formula..



"Jacob Skaria" wrote:

Dear Kashya, try replacing the CountIF function with Match.

If this post helps click Yes
---------------
Jacob Skaria


"Kashyap" wrote:

I need to delete rows if sheet1 Column F not equal to Sheet3 G5:G10

I tried below code, but it works very very slow.. Actually there are around
25000+ records..

sub deleterows()
Set MySheet = Sheets("Sheet1")
LR = MySheet.Cells(Rows.Count,"F").End(xlup).Row
For i = LR to 2 Step -1
With Sheets("Sheet3")
If WorksheetFunction.Countif(.Range("G5:G10"),MySheet .Cells(i,"F"))0 Then
MySheet.Rows(i).EntireRow.Delete
End If
End With
Next i
End Sub


Any better one..?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Delete rows if not as range

Dear Kashya

I have not done any major changes to your code. Please try and feedback.

Sub deleterows()
Application.ScreenUpdating = False
Set MySheet = Sheets("Sheet1")
Set MyRange = Sheets("Sheet3").Range("G5:G10")
LR = MySheet.Cells(Rows.Count, "F").End(xlUp).Row
For i = LR To 2 Step -1
If WorksheetFunction.CountIf(MyRange, MySheet.Cells(i, "F")) 0 Then
MySheet.Rows(i).EntireRow.Delete
End If
Next i
Application.ScreenUpdating = True
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Kashyap" wrote:

Hi, would you please help me out with the formula..



"Jacob Skaria" wrote:

Dear Kashya, try replacing the CountIF function with Match.

If this post helps click Yes
---------------
Jacob Skaria


"Kashyap" wrote:

I need to delete rows if sheet1 Column F not equal to Sheet3 G5:G10

I tried below code, but it works very very slow.. Actually there are around
25000+ records..

sub deleterows()
Set MySheet = Sheets("Sheet1")
LR = MySheet.Cells(Rows.Count,"F").End(xlup).Row
For i = LR to 2 Step -1
With Sheets("Sheet3")
If WorksheetFunction.Countif(.Range("G5:G10"),MySheet .Cells(i,"F"))0 Then
MySheet.Rows(i).EntireRow.Delete
End If
End With
Next i
End Sub


Any better one..?

Reply
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
delete row and 3 rows below by range selected Corey Excel Programming 2 November 28th 06 08:14 AM
Help with filter Range & delete rows Les[_8_] Excel Programming 2 October 19th 06 07:33 AM
Auto delete rows within a specified range [email protected] Excel Programming 2 June 14th 06 03:30 PM
Delete Unwanted Rows (Help with Range) Santa-D Excel Programming 1 June 13th 06 10:16 AM
Delete a range of rows ? SpookiePower Excel Programming 6 January 24th 06 03:24 PM


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

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

About Us

"It's about Microsoft Excel"