On UrbanPro

View My Profile       Proud to be a Teacher       Write a Review  

Sunday, February 8, 2015

VBA Code to Remove Specific Value from a table in MS Excel

Use the Below VBA Code to Remove Specific Value from a table in MS Excel from your active worksheet


 Sub RemoveSpecificValue()  
 'Removing Specific Values whose begins with "FR0"  
    ActiveSheet.Range("A:G").AutoFilter Field:=1, Criteria1:="=FR0*" _  
     , Operator:=xlAnd  
   ' Delete AutoFiltered rows except the header  
   lr = Cells(Rows.Count, 1).End(xlUp).Row  
   If lr > 1 Then  
     Range("A2:A" & lr).SpecialCells(xlCellTypeVisible).EntireRow.Delete  
   End If  
 End Sub