Ads

Wednesday, April 15, 2009

Macros anyone?

The only area of Excel I am deficient in is creating Macros, which I am currently trying to remedy. But I need help. I have a data table with several thousand rows that I want to export to another new, blank workbook (we'll call it "MASTER") using a Macro. The catch is there are several hundred rows I want to delete in the same process. These rows all have an identifier- for this example, in column K any cell with the value of "DELETE", I want to delete that entire row. How can I write a macro to accomplish this or if it is even possible?

This is not a one and done deal, this is a process I will have to repeat many times. Also, the column with the "DELETE"s will not be the same column every time. Is there a way to reference a cell to tell it which columns the "DELETE"s are in?  Here's what I have so far:

Sub DelEmptyRow()
Rng = Selection.Rows.Count
ActiveCell.Offset(0, 0).Select
Application.ScreenUpdating = False
For i = 1 To Rng
If ActiveCell.Value = "DELETE" Then   
Selection.EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Select
End If
Next i
Application.ScreenUpdating = True
End Sub

Thanks again for your help..

1 comment:

Blogger said...

Searching for the Best Dating Site? Create an account to find your perfect date.