checking if a cell contains text and deleting it

jaycee

Active Member
Joined
Jul 22, 2009
Messages
323
I have a column (D) that contains letters and numbers ie e6788764, But if this row contains the letters "D", "F", "K" or "S" then I need to delete those letters but keep the numbers.
The length of the numbers also differ.

Any ideas how this can be done?
:confused:
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
This will do the job

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(D1, "D", ""),"F", ""),"K", ""),"S", "")
 
Upvote 0
Not sure if there is loads of data, if so you might want to replace the offending cells?

Anyway, example of simplified bit of code:
Code:
Sub try()
x = 2
Do Until x = 10
If Left(Cells(x, 4), 1) = "d" Then
Cells(x, 4) = Right(Cells(x, 4), Len(Cells(x, 4)) - 1)
End If
x = x + 1
Loop
End Sub
 
Upvote 0
That fromula goes in row 1 of a helper column,
is dragged down to the end of the data,
and (perhaps) copy/Paste Special Values the result into Column D.
 
Upvote 0
I tried to put it in row "D" but this then deletes when I put the data in.

I have also tried in a seperate column, but this only copies what was in the original row "D" admittedly with those letters deleted, but now in the wrong column?
 
Upvote 0
Highlight the range with the values in column D.

Hit CONTROL+H (Find & Replace)
Find: E
Replace: <leave this blank>

Hit Replace All.

Repeat for other letters in the column that you wish to remove.
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,397
Members
448,957
Latest member
Hat4Life

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