Please Help! Delete all cells in range except "1934 - 1934"

C

cdubuque

I've been driving myself crazy trying to figure this out! I have
spreadsheet with a huge range of garbage cells, and I just need t
extract the cells in a specific date format. IE: 1991 - 1995. A strin
of 11 characters (including spaces).

I am looking to delete all cells that do not fit that format and remov
all blank cells.

Any help on this is greatly appeciated!

Thanks
 
L

Living the Dream

Hi

Lets assume your sheet is the following:

mySht is the Name of your Sheet
myRng is the Range of the column that the code has to run down
myVal is the Date string match that you want to find in myRng
c represents every Cell within myRng

Change the above to fit the code below.

Sub RemoveGarbage()

Dim mySht As Worksheet
Dim myRng As Range
Dim myVal As Range
Dim c As Range

Set mySht = Sheets("Sheet1")
Set myRng = mySht.Range("F2:F10")
Set myVal = [F1]

For Each c In myRng
If Not c <> myVal Then
With c
.EntireRow.Delete xlUp
End With
End If
Next c

End Sub

HTH
Mick.
 

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