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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Several macro in one macro

Status
Not open for further replies.

heimly

Technical User
Jul 22, 2010
5
NO
I use Excel 2007.
I wish to delete row that contain Various contents

I have tryed following code. It stop on what = "Fail" or "Loggoff"

sub Fail()
Dim rng as Range
Dim what As String
what = "Fail" or "Loggoff"
Do
Set rng = ActiveSheet.UsedRange.Find(what)
If rng Is Nothing then
Exit Do
Else
Rows(rng.Row).Delete
End If
Loop
End sub

Thanks Erik
 
Your variable "what" can contain a single string.
Find can only look for a single string.
So for starters change
what = "Fail" or "Loggoff"
to
what = "Fail"
and loop around a second time for he other search value.

If you lookup VBA help on the FindNext method you will find some useful code to adapt.

Gavin
 



You must do a Find using one value at a time.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Code:
...
Dim what As String
For Each what in Array("Fail", "Loggoff")
   Do
...
   Loop
Next
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top