Is there a way to delete cells in a column with "/" or "(insert numbers)" through VBA?

afinancialanaylst

New Member
Joined
Sep 29, 2016
Messages
2
Hi all,
I was wondering if anyone knew a way to create a macro to delete specific cells from a column of figures that have a "/" in them (eg. 13/03) or a string of numbers (e.g. looking for 2013 in a cell with 5562013).
I've had a think about using either IF, MATCH, VLOOKUP or using LEFT/MID/RIGHT with specific text strings but I can't wrap my head around the proper programming.
The macro only needs to run through a specific column, and will be used every time in that same column.
Thanks!
 
What column are these values in?
Just delete the cell and shift up or delete entire row?
 
Upvote 0
You can record a macro that replaces the / with 1/0 or a blank, then delete via the specialcells method (F5-Special).
 
Last edited:
Upvote 0
Try this:

Code:
Sub Test()
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "G").End(xlUp).Row
    For i = 1 To Lastrow
        If InStr(Cells(i, "G").Value, "/") Then Cells(i, "G").ClearContents
    Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0

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