PC Review


Reply
Thread Tools Rate Thread

Deleting excel rows based on multiple criteria

 
 
suyog_linux
Guest
Posts: n/a
 
      18th Apr 2008
Hi All,

I am looking for hel to delete data from one of the huge excel file I
have.
Actually, I have two excel files, one contains data regarding Users
with UserName as primary key and other excel file contains some of
user ID's which also exist in first file.

I would like to get help with a VBA code which will take inputs from
one of the excel file search for that UserName in the file and delete
the whole row if UserName is matched.

Appreciating the help in this regard.

Thanks,
Suyog Shah
 
Reply With Quote
 
 
 
 
Ken
Guest
Posts: n/a
 
      18th Apr 2008
Suyog

If you are going to be doing this often you could write code, but, if
you are just doing it once, or only occasionally it should be pretty
easy to:

1. On the sheet from which you want to delete the duplicates, use a
MATCH function to identify rows that should be deleted.

2. Sort that worksheet so all the errors (#NA) get put together.

3. Delete those rows

4. Sort in original order. If the original order is important, you
need to make sure you can resort to regain that order before you
delete. You may need to insert a column and number the rows
sequentially so you will be able to return to te the original order
after youe delete.

If for some reason you won't be able to sort your data after marking
the duplicate rows with the MATCH function, you can use Go To Special
(F5) to select all the errors at once, then delete the entire rows all
at once.

Good luck.

Ken
Norfolk, Va

On Apr 17, 11:55*pm, suyog_linux <suyog.s...@gmail.com> wrote:
> Hi All,
>
> I am looking for hel to delete data from one of the huge excel file I
> have.
> Actually, I have two excel files, one contains data regarding Users
> with UserName as primary key and other excel file contains some of
> user ID's which also exist in first file.
>
> I would like to get help with a VBA code which will take inputs from
> one of the excel file search for that UserName in the file and delete
> the whole row if UserName is matched.
>
> Appreciating the help in this regard.
>
> Thanks,
> Suyog Shah


 
Reply With Quote
 
Anant.Basant@gmail.com
Guest
Posts: n/a
 
      18th Apr 2008
On Apr 18, 8:55*am, suyog_linux <suyog.s...@gmail.com> wrote:
> Hi All,
>
> I am looking for hel to delete data from one of the huge excel file I
> have.
> Actually, I have two excel files, one contains data regarding Users
> with UserName as primary key and other excel file contains some of
> user ID's which also exist in first file.
>
> I would like to get help with a VBA code which will take inputs from
> one of the excel file search for that UserName in the file and delete
> the whole row if UserName is matched.
>
> Appreciating the help in this regard.
>
> Thanks,
> Suyog Shah


Hi Suyog,

Try the following code.

Sub DelUsers()
' User data is on data sheet. IDs to delete
' is a list of IDs on sheet "IDsToDel"
Dim rUID As Range
Dim rData As Range
Dim c As Range, x As Range

Set rData = Sheets("Data").Range("A1").CurrentRegion.Columns(1)
Set rData = rData.Offset(1, 0).Resize(rData.Rows.Count - 1, 1)
'Debug.Print rData.Address

Set rUID = Sheets("IDsToDel").Range("A1").CurrentRegion

For Each c In rUID.Cells
For Each x In rData.Cells
If LCase(c.Value) = LCase(x.Value) Then
x.EntireRow.Delete
Exit For
End If
Next x
Next c
End Sub

Anant
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting Rows based on multiple criteria cardioblack@gmail.com Microsoft Excel Programming 0 11th Jan 2007 07:40 PM
Deleting blanks rows based on multiple criteria Pedros Microsoft Excel Programming 1 27th Jul 2006 05:44 AM
Deleting rows based on multiple criteria Sandip Shah Microsoft Excel Programming 3 12th Jul 2004 01:57 PM
Deleting rows based on criteria John Walker Microsoft Excel Programming 2 12th Dec 2003 08:37 PM
Deleting rows in Excel based on criteria SteveM Microsoft Excel Misc 3 20th Nov 2003 11:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:15 PM.