![]() |
Remove all rows that contain letters
I'm trying to create a macro or something to remove an entire row, if any
cell in the row contains any letter.I plan to use a button to automate the process. Thank you |
Remove all rows that contain letters
This sub will do it, if by "contains any letter" you mean "contains any
non-numeric cell." You need to supply the range - any continuous range that spans the rows you want to check. It uses the COUNT function and the COUNTA function as a way of finding non-numeric cells (since these will differ if there are any). Public Sub RemoveAlphaRows(RowsToCheck As Range) Dim RowNo As Integer, CheckRow As Range Dim NumCount As Integer, AllCount As Integer For RowNo = RowsToCheck.Rows.Count To 1 Step -1 Set CheckRow = RowsToCheck.Range("A1").Offset(RowNo - 1, 0).EntireRow NumCount = WorksheetFunction.Count(CheckRow) AllCount = WorksheetFunction.CountA(CheckRow) If AllCount < NumCount Then CheckRow.Delete Next RowNo End Sub "fred" wrote: I'm trying to create a macro or something to remove an entire row, if any cell in the row contains any letter.I plan to use a button to automate the process. Thank you |
All times are GMT +1. The time now is 04:06 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com