Delete Cells with numbers, Delete Cells with dashes

hellothere4

New Member
Joined
May 9, 2011
Messages
17
Hello, I am trying to delete cells along the first column which contains numbers, and then I need another function which deletes cells that contain "-". I didn't get very far. :cool:

Sub Macro4()
'
' Macro4 Macro
'

'
Columns("A:A").Select
End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Here's a start. i made some assumptions. You may have to modify to suit.

Code:
Sub Delete_Numbers_Dash()

    Dim vList As Variant, c As Variant, Found As Range

    vList = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, "-")
    
    For Each c In vList
        Do
            ' Delete the found cell and shift cells up.
            If Not Found Is Nothing Then Found.Delete Shift:=xlShiftUp
            
            ' Clear the found cell
            'If Not Found Is Nothing Then Found.ClearContents
            
            ' Delete the entire row
            'If Not Found Is Nothing Then Found.EntireRow.Delete
            
            Set Found = Columns("A").Find(What:=CStr(c), _
                                          LookIn:=xlValues, _
                                          LookAt:=xlPart, _
                                          SearchOrder:=xlByRows, _
                                          SearchDirection:=xlNext, _
                                          MatchCase:=False)
                                          
        Loop Until Found Is Nothing
    Next c
    
    MsgBox "Cells deleted."
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,582
Messages
6,179,670
Members
452,936
Latest member
anamikabhargaw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top