find/delete row when cell has less than 16 alphanumeric characters

P

Peruanos72

Hello,

How can I find a cell in column "E" that has less than 16 characters and then
delete that row?

Also, is there also a way to find duplicate cells in a column and delete
those rows containing those duplicate cells? Ex: three rows of data are
duplicates so i want to delete 2 of those rows.

Thanks in advance!!!
 
J

Jacob Skaria

To delete rows with less than 16 characters use the below macro. For removing
duplicates Select range and from Advanced Filter option check unique records
only. You can copy that to another sheet.

For running the macro Set the Security level to low/medium in
(Tools|Macro|Security). 'Launch VBE using short-key Alt+F11. Insert a module
and paste the below code. Save. Get back to Workbook. Tools|Macro|Run
MyMacro()

Sub MyMacro()

lngRow = ActiveSheet.Cells(Rows.Count, "E").End(xlUp).Row
For lngTemp = lngRow To 1 Step -1
If Len(Trim(Range("E" & lngTemp))) < 16 Then
Rows(lngTemp).Delete
End If
Next

End Sub
 
P

Peruanos72

Thanks Jacob.

Jacob Skaria said:
To delete rows with less than 16 characters use the below macro. For removing
duplicates Select range and from Advanced Filter option check unique records
only. You can copy that to another sheet.

For running the macro Set the Security level to low/medium in
(Tools|Macro|Security). 'Launch VBE using short-key Alt+F11. Insert a module
and paste the below code. Save. Get back to Workbook. Tools|Macro|Run
MyMacro()

Sub MyMacro()

lngRow = ActiveSheet.Cells(Rows.Count, "E").End(xlUp).Row
For lngTemp = lngRow To 1 Step -1
If Len(Trim(Range("E" & lngTemp))) < 16 Then
Rows(lngTemp).Delete
End If
Next

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top