Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to delete rows with certain values 1

Status
Not open for further replies.

DSerr77

Technical User
Jul 21, 2004
42
US
I am trying to write a Macro that will evaluate the contents of a cloumn and delete the entire row if the value in a cell meets a certain criteria. Here is what I have so far:

Sub Delete_Row()
Dim Mvalue
Range(A1).select
Do Until Mvalue = Null
Mvalue = ActiveCell.Value
If (ActiveCell.Value = 2)Then
'(I would like to be able to control this value)
'Need to know how to select and delete row
End If
ActiveCell.Offset(1,0).select
Loop

End Sub

Appreciate any help
 
Autofilter Method of range class failed ??
 
PHV the value of last row = 25014 when I step through.
 
DSerr77 said:
I need that variable to change.
So use one of the methods mentioned in an earler post, like this one:
Code:
MyVal = InputBox("What do you want to delete?", "Delete Variable")
...
Criteria1:=MyVal

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ181-2886 before posting.
 
John,

Thanks for sticking with me. I tried using the previous MyVal code and I was getting the auto filter method error. I realize that is because I was testing the code on a one column worksheet. Once I filled columns A-G with data this works great. thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top