Hello there, im new to macros got a macro an im trying to do a filter with a inputbox that deletes the rows if it dosent found the word or if the cell is blank in the column, heres the code:
it deletes everything :P i just whant to delete the words of the inputbox and rows containing blank cellsSub filtro() Dim lr As Long Dim box box = InputBox("Filtrar:") lr = Range("D" & Rows.Count).End(xlUp).Row With Range("D1:D" & lr) .AutoFilter Field:=1, Criteria1:="<>box" .Offset(1).EntireRow.Delete .AutoFilter End With End Sub
well thats all thanks.
Last edited by babar48; 07-14-2011 at 10:00 PM. Reason: poor english
the result of Inputbox method depends on the TYPE of data:
If the number plz, change to
if the text (string)box = InputBox("Filtrar:",Type:=1)
if the rangebox = InputBox("Filtrar:", Type:=2)
AND also changebox = InputBox("Filtrar:", Type:=8)
to.AutoFilter Field:=1, Criteria1:="<>box"
.AutoFilter Field:=1, Criteria1:="<>" & box
Last edited by tigertiger; 07-14-2011 at 07:28 PM.
Hi babar48, you were close. Notice the "<>" & box inIf it remains in quotes then the criteria will always be box and that's it.Sub filtro() Dim lr As Long Dim box As String box = InputBox("Filtrar en Categorķa:") lr = Range("D" & Rows.Count).End(xlUp).Row With Range("D1:D" & lr) .AutoFilter Field:=1, Criteria1:="<>" & box .EntireRow.Delete .AutoFilter End With End Sub
Please leave a message after the beep!
thanks guys, problem solved :D
If your problem has been solved please mark your thread as solved. Also, if you feel that members of this forum have helped you out then don't be bashful and tap their scales (located at the top right of each post).
Kind Regards:
Please leave a message after the beep!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks