Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Row deletion based on matches

Hi,
I got this program from David McRitchie's website and I tweaked it a little
bit.
It works great with alphabets matching in columns A and B. It deletes the
whole row when col A and B contain the same alphabet.
I was wondering how I would change it in order to work with numbers instead
of alphabets. And how can I have it delete the rows that DO NOT match and
keep the ones that match? Any help would be appreciated. Thanks

Sub Delete_rows_based_on_ColA_ColB()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim cell As Range, rng As Range, i As Long
Set rng = Columns("A").SpecialCells(xlConstants, xlTextValues)
For i = rng.Count To 1 Step -1
If LCase(rng(i).Value) = LCase(rng(i).Offset(0, 1).Value) Then
rng(i).EntireRow.Delete

Next i
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Row deletion based on matches

Hi Sean

Without code you can do this (see the basic examples first on Debra's site)
http://www.contextures.com/xladvfilter02.html#Match

Select the rows and delete them

If you want a macro post back


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Sean" wrote in message ...
Hi,
I got this program from David McRitchie's website and I tweaked it a little
bit.
It works great with alphabets matching in columns A and B. It deletes the
whole row when col A and B contain the same alphabet.
I was wondering how I would change it in order to work with numbers instead
of alphabets. And how can I have it delete the rows that DO NOT match and
keep the ones that match? Any help would be appreciated. Thanks

Sub Delete_rows_based_on_ColA_ColB()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim cell As Range, rng As Range, i As Long
Set rng = Columns("A").SpecialCells(xlConstants, xlTextValues)
For i = rng.Count To 1 Step -1
If LCase(rng(i).Value) = LCase(rng(i).Offset(0, 1).Value) Then
rng(i).EntireRow.Delete

Next i
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Row deletion based on matches

Hi Ron,
Thanks for the reply. I have about 20 files with atleast 6000 rows of data
in each so I was thinking that a macro would be best. What would you suggest?
Please let me know.
Thanks
Sean

"Ron de Bruin" wrote:

Hi Sean

Without code you can do this (see the basic examples first on Debra's site)
http://www.contextures.com/xladvfilter02.html#Match

Select the rows and delete them

If you want a macro post back


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Sean" wrote in message ...
Hi,
I got this program from David McRitchie's website and I tweaked it a little
bit.
It works great with alphabets matching in columns A and B. It deletes the
whole row when col A and B contain the same alphabet.
I was wondering how I would change it in order to work with numbers instead
of alphabets. And how can I have it delete the rows that DO NOT match and
keep the ones that match? Any help would be appreciated. Thanks

Sub Delete_rows_based_on_ColA_ColB()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim cell As Range, rng As Range, i As Long
Set rng = Columns("A").SpecialCells(xlConstants, xlTextValues)
For i = rng.Count To 1 Step -1
If LCase(rng(i).Value) = LCase(rng(i).Offset(0, 1).Value) Then
rng(i).EntireRow.Delete

Next i
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Row deletion based on matches

Hi Sean

Advanced filter is a bit faster and you can code that also if you want but try this first.

This is a example for numbers

Sub Delete_rows_based_on_ColA_ColB2()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim cell As Range, rng As Range, i As Long
Set rng = Columns("A").SpecialCells(xlConstants, xlNumbers)
For i = rng.Count To 1 Step -1
If rng(i).Value < rng(i).Offset(0, 1).Value Then
rng(i).EntireRow.Delete
End If
Next i
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Sean" wrote in message ...
Hi Ron,
Thanks for the reply. I have about 20 files with atleast 6000 rows of data
in each so I was thinking that a macro would be best. What would you suggest?
Please let me know.
Thanks
Sean

"Ron de Bruin" wrote:

Hi Sean

Without code you can do this (see the basic examples first on Debra's site)
http://www.contextures.com/xladvfilter02.html#Match

Select the rows and delete them

If you want a macro post back


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Sean" wrote in message ...
Hi,
I got this program from David McRitchie's website and I tweaked it a little
bit.
It works great with alphabets matching in columns A and B. It deletes the
whole row when col A and B contain the same alphabet.
I was wondering how I would change it in order to work with numbers instead
of alphabets. And how can I have it delete the rows that DO NOT match and
keep the ones that match? Any help would be appreciated. Thanks

Sub Delete_rows_based_on_ColA_ColB()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim cell As Range, rng As Range, i As Long
Set rng = Columns("A").SpecialCells(xlConstants, xlTextValues)
For i = rng.Count To 1 Step -1
If LCase(rng(i).Value) = LCase(rng(i).Offset(0, 1).Value) Then
rng(i).EntireRow.Delete

Next i
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Row deletion based on matches

Hi Ron,
It works perfectly for me! Thanks so much.
Sean

"Ron de Bruin" wrote:

Hi Sean

Advanced filter is a bit faster and you can code that also if you want but try this first.

This is a example for numbers

Sub Delete_rows_based_on_ColA_ColB2()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim cell As Range, rng As Range, i As Long
Set rng = Columns("A").SpecialCells(xlConstants, xlNumbers)
For i = rng.Count To 1 Step -1
If rng(i).Value < rng(i).Offset(0, 1).Value Then
rng(i).EntireRow.Delete
End If
Next i
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Sean" wrote in message ...
Hi Ron,
Thanks for the reply. I have about 20 files with atleast 6000 rows of data
in each so I was thinking that a macro would be best. What would you suggest?
Please let me know.
Thanks
Sean

"Ron de Bruin" wrote:

Hi Sean

Without code you can do this (see the basic examples first on Debra's site)
http://www.contextures.com/xladvfilter02.html#Match

Select the rows and delete them

If you want a macro post back


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Sean" wrote in message ...
Hi,
I got this program from David McRitchie's website and I tweaked it a little
bit.
It works great with alphabets matching in columns A and B. It deletes the
whole row when col A and B contain the same alphabet.
I was wondering how I would change it in order to work with numbers instead
of alphabets. And how can I have it delete the rows that DO NOT match and
keep the ones that match? Any help would be appreciated. Thanks

Sub Delete_rows_based_on_ColA_ColB()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim cell As Range, rng As Range, i As Long
Set rng = Columns("A").SpecialCells(xlConstants, xlTextValues)
For i = rng.Count To 1 Step -1
If LCase(rng(i).Value) = LCase(rng(i).Offset(0, 1).Value) Then
rng(i).EntireRow.Delete

Next i
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub






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
#Ref! after row deletion Rick Excel Discussion (Misc queries) 3 March 19th 10 04:39 PM
Row Deletion based on condition. Manish Excel Discussion (Misc queries) 4 June 9th 09 07:15 PM
name deletion rk0909 Excel Discussion (Misc queries) 2 January 4th 08 11:03 PM
simple row deletion lawson Excel Discussion (Misc queries) 3 October 17th 07 06:57 PM
Row Deletion Dan Excel Programming 3 September 1st 04 10:40 PM


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