Delete a list of rows

J

John Fevens

I have a number of workbooks that contain multiple tabs.


I have a list of rows that are duplicated on one or more tabs. Is
there quick and dirty way for me to run a macro deleting the rows from
the list??


I.e.

My list contains the following columns
A B C D E
ref# worksheet row worksheet row


I would like to "clear" all of the references at D and E.
 
T

Tom Ogilvy

You can loop through your list and do the deletions, however, you list would
need to be sorted by row, so you always start with the highest row on a
sheet and work down to the lowest row - otherwise, the row numbers will
change when you delete a lower row and you will start deleting the wrong
row.

so assume you are looping through column A using i

for i = numrows to 1 step -1
worksheets(cells(i,4).value).Rows(Cells(i,5).Value) _
.EntireRow.Delete
Next
 
J

John Fevens

Tom,


Thanks for you response.

A couple of questions....if I change delete to clear will that also
work? I would rather leave the row nums in tact.

Alos, when I did a trila of your code I am getting a inval or
unqualified ref.


Maybe someday I should just break down and actaully learn some VBA!



Bill



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
T

Tom Ogilvy

In column C and D of the active sheet I had (row 1 to 6)

Sheet2 1
Sheet1 3
Graph Data 5
Sheet2 10
Sheet2 15
Sheet1 10

Sheets were Sheet1, Sheet2, Graph Data, Sheet4. Sheet4 was active and
contained the above.

Sub BBB()
numrows = 6
For i = numrows To 1 Step -1
Worksheets(Cells(i, 4).Value).Rows(Cells(i, 5).Value) _
.EntireRow.Clear
Next

End Sub

worked fine for me. Adapt it to your situation.
 
Top