Macro help


Posted by Steve Carr on December 05, 2001 8:57 AM

Hi, I'm having some trouble and need some help!.

I'm trying to automate a procedure. This procedure needs to find a particular style of characters (_vti*) within a cell of a column (there are 3 columns altogether).

Once, the cell has been found within the coulumn it needs to delete the entire row (deleting its corresponding column cell in the other 2 columns).

Basically,

find all "_vti*" cell's
delete contents of that cell
also, delete corresponding coulmn cell's (in other column's).

I hope someone can help me. It will be very much appreciated if you can.

Thanks in advance and kind regards,

Steve



Posted by Damon Ostrander on December 05, 2001 10:55 AM

Hi Steve,

Here's a macro that does this for column C. I think you will see how to modify it for use on some other column. I'm assuming that in your "_vti*" the asterisk is meant as a character and not a wildcard. If you do intend it to be a wildcard just change the

If Cells(iRow, 3) = SpecValue ...

test to

If Cells(iRow, 3) Like SpecValue ...

Here's the code:

Sub DeleteSpecifiedRows()

' This macro deletes all rows on the active worksheet
' that have the user input specified value in column C.

Dim iRow As Long
Dim SpecValue As String

SpecValue = InputBox("Enter column C value", "Selective Row Deletion")

If SpecValue = "" Then Exit Sub

For iRow = ActiveSheet.UsedRange.Rows.Count To 1 Step -1
If Cells(iRow, 3) = SpecValue Then Rows(iRow).Delete
Next iRow

End Sub

Happy computing.

Damon