PC Review


Reply
Thread Tools Rate Thread

Delete rows based on an array

 
 
vbaker74@yahoo.com
Guest
Posts: n/a
 
      10th Mar 2008
So.. I have a large worksheet of information for which I need to
delete certain rows based on a list in another worksheet. I need a
delete row function that will look up the value in another worksheet
and delete the row based on that value. Can anyone help?

~Vic
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      10th Mar 2008
Probably. If you would furnish the names or numbers of the sheets, the range
where the list is stored and which sheet it is in; and whether the data to be
compared in the other sheet is in a specific column or row and which it is;
or if it is radomly located within the sheet.

"(E-Mail Removed)" wrote:

> So.. I have a large worksheet of information for which I need to
> delete certain rows based on a list in another worksheet. I need a
> delete row function that will look up the value in another worksheet
> and delete the row based on that value. Can anyone help?
>
> ~Vic
>

 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      10th Mar 2008
Let's say Sheet2 has the data and Sheet1 in column A has the list of rows we
want deleted from Sheet2. For example, in Sheet1 in A1 thru A4 we have:

1
5
7
11

The following macro will remove these rows from Sheet2:

Sub rowkiller()
Dim rkill() As Integer

Sheets("Sheet1").Activate
n = Cells(Rows.Count, 1).End(xlUp).Row
ReDim rkill(1 To n)
For i = 1 To n
rkill(i) = Cells(i, 1).Value
Next

Sheets("Sheet2").Activate
Set rgkill = Cells(rkill(1), 1)
For i = 2 To n
Set rgkill = Union(rgkill, Cells(rkill(i), 1))
Next
rgkill.EntireRow.Delete
End Sub

--
Gary''s Student - gsnu2007f


"(E-Mail Removed)" wrote:

> So.. I have a large worksheet of information for which I need to
> delete certain rows based on a list in another worksheet. I need a
> delete row function that will look up the value in another worksheet
> and delete the row based on that value. Can anyone help?
>
> ~Vic
>

 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      10th Mar 2008
Hi Vic

See
http://www.rondebruin.nl/delete.htm

See the tip below the first example

If Not IsError(Application.Match(.Value, _
Array("jelle", "ron", "dave"), 0)) Then .EntireRow.Delete

'Or use this one with Application.Match if you want to check more values.
'in the cell. You can also use a range with the values to delete.
'Replace Array("jelle", "ron", "dave") with Sheets("Sheet1").Range("A1:A200")



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


<(E-Mail Removed)> wrote in message news:65e292c5-52a5-4fe6-babe-(E-Mail Removed)...
> So.. I have a large worksheet of information for which I need to
> delete certain rows based on a list in another worksheet. I need a
> delete row function that will look up the value in another worksheet
> and delete the row based on that value. Can anyone help?
>
> ~Vic

 
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
Macro to delete rows based based between two specific dates Trey24 Microsoft Excel Misc 0 25th Aug 2009 05:05 PM
Delete Rows in an existing array in Excel wlfoote Microsoft Excel Crashes 1 24th Aug 2009 12:11 AM
Delete Rows based on # of rows (no variable?) DanaK Microsoft Excel Programming 7 3rd Nov 2008 12:11 AM
Delete rows based on value... =?Utf-8?B?R29yZG9u?= Microsoft Excel Programming 3 15th Sep 2006 09:14 PM
help! how to delete useless rows in 2 dim array by VBA xiang Microsoft Excel Programming 6 30th Dec 2005 02:11 PM


Features
 

Advertising
 

Newsgroups
 


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