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: 14
Default Deleting excel rows based on multiple criteria

On Apr 18, 8:55*am, suyog_linux 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
 
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
Deleting Rows based on multiple criteria [email protected] Excel Programming 0 January 11th 07 07:40 PM
Deleting blanks rows based on multiple criteria Pedros[_14_] Excel Programming 1 July 27th 06 05:44 AM
Deleting entire rows based on certain criteria Nan[_4_] Excel Programming 1 July 12th 04 05:04 PM
Deleting rows based on multiple criteria Sandip Shah Excel Programming 3 July 12th 04 01:57 PM
Deleting rows based on criteria John Walker[_2_] Excel Programming 2 December 12th 03 08:37 PM


All times are GMT +1. The time now is 06:26 PM.

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"