Hi,
I am needing a macro that will delete entire rows (up to 3000 rows) not containing a specified value(i.e. "100") in Column C. Row 1 contains titles for the columns.I have tried this on my own, but I am having trouble. I have seen a few that when the macro is started it propts you to input the value that you want to not delete. Any help would be appreciated. Solved
Last edited by jhmayor03; 02-02-2012 at 10:29 AM. Reason: Solved
You could use this - It will ask for a number using an inputbox and any row NOT containing the number will be deleted
Hope this helps.Sub srchDel() Dim questDel As Long questDel = Application.InputBox(Prompt:= _ "Please Select a Number as Criteria Not to Delete", _ Title:="InputBox Method", Type:=1) 'Type 1 is a number, 2 is a string lrow = Cells(Rows.Count, "C").End(xlUp).Row Set xRng = Columns("C:C") Set yRng = Range("C2:C" & lrow) On Error Resume Next With xRng .AutoFilter Field:=1, Criteria1:="<>" & questDel, Operator:=xlAnd yRng.SpecialCells(xlCellTypeVisible).EntireRow.Delete .AutoFilter End With On Error Goto 0 End Sub
Anthony
“Confidence never comes from having all the answers; it comes from being open to all the questions.”
PS: Remember to mark your questions as Solved once you are satisfied and rate the answer(s) questions.”
PS: You could set the Type to the various attributes for the Inputbox depending on what you are searching for
0 A formula
1 A number
2 Text (a string)
4 A logical value (True or False)
8 A cell reference, as a Range object
16 An error value, such as #N/A
64 An array of values
Hope this helps.
Anthony
“Confidence never comes from having all the answers; it comes from being open to all the questions.”
PS: Remember to mark your questions as Solved once you are satisfied and rate the answer(s) questions.”
-delete - double post
This Macro works perfectly!!! Thanks so much for the help!![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks