Delete cell if value does not equal

Melrose0507

New Member
Joined
Jul 19, 2011
Messages
22
Hello everyone.

I have tried searching everywhere and can not find out how to accomplish what I need. I am creating a template using macros to reformat the raw data and am stuck. Here is what I need to do:

In column I, I need to identify all cells that only contain letters and delete that cell only and shift left. If the cell has numbers, it is to remain. The cells with numbers always begin with the number 2. The actual letters may vary.

I can find macros that will allow you to delete the row but can not find how to delete just the cell.


Please help?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Try

Code:
Sub test2()
Dim LR As Long, i As Long
LR = Range("I" & Rows.Count).End(xlUp).Row
For i = LR To 1 Step -1
    With Range("I" & i)
        If Left(.Value, 1) <> "2" Then .Delete shift:=xlShiftToLeft
    End With
Next i
End Sub
 
Upvote 0
I am checking it out now but am running to a meeting. Thanks for the quick reply. I will let you know how it works in about an hour.
 
Upvote 0
That worked perfectly. You did in a couple of minutes what I have researched hours trying to figure out. I huge thank you. This will save our team so much time.
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,710
Members
452,939
Latest member
WCrawford

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