deleting rows that are not equal to a value entered from an input box, Please Help Me
Hi
I'm trying to make an excel document that, when you open it, it pops up an Input box. It will ask you for a number. Then once you hit enter it will search the first sheet in the first column and if the value is different then the one that you put in the input box it will delete the entire row. Thank you so much Laura |
deleting rows that are not equal to a value entered from an input box, Please Help Me
Try this one Laura
A1 must have a header Sub Delete_with_Autofilter() Dim FindString As String Dim rng As Range FindString = InputBox("Enter your Findstring") If Trim(FindString) < "" Then With ActiveSheet .Columns("A").AutoFilter Field:=1, Criteria1:="<" & FindString With ActiveSheet.AutoFilter.Range On Error Resume Next Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _ .SpecialCells(xlCellTypeVisible) On Error GoTo 0 If Not rng Is Nothing Then rng.EntireRow.Delete End With .AutoFilterMode = False End With End If End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "Laura" wrote in message om... Hi I'm trying to make an excel document that, when you open it, it pops up an Input box. It will ask you for a number. Then once you hit enter it will search the first sheet in the first column and if the value is different then the one that you put in the input box it will delete the entire row. Thank you so much Laura |
All times are GMT +1. The time now is 10:00 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com