Delete Text from String

badinvestor

New Member
Joined
Dec 28, 2009
Messages
21
Hi all,
I have what I think is a simple question but can't quite get it.
I have the following table and 700+ rows, what I'm looking to do is either by macro or formula find a way to remove all the chars ACDRUVQ from col E and have remaining char(s) put into col F. I have tried a combo of =MID and =FIND such as =MID(E20,FIND("A",E20,1)+3,9) but can't get exactly what I need since the char. can be in any position in the string. Any help would be great!

Excel Workbook
ABCDEF
5System CodeForm IDTokenForm NameAvailable Function CodesGranted Function Codes or Y for access
19AMAM06AM06.4Asset Class Depreciation Rates+-ACIto remove ACDRUVQ
20AMAM06AM06.5Asset Class Depreciation Rate Detail+-ACDINPto remove ACDRUVQ
21AMAM06AM06.6Depreciation Allocation+-ACDINPRUto remove ACDRUVQ
22AMAM07AM07.1LocationNPACIDto remove ACDRUVQ
AmInquiry
Excel 2003
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Presuming you want results like in Col F
Excel Workbook
ABCDEF
1System CodeForm IDTokenForm NameAvailable Function CodesGranted Function Codes or Y for access
2AMAM06AM06.4Asset Class Depreciation Rates+-ACI+-I
3AMAM06AM06.5Asset Class Depreciation Rate Detail+-ACDINP+-INP
4AMAM06AM06.6Depreciation Allocation+-ACDINPRU+-INP
5AMAM07AM07.1LocationNPACIDNPI
6
Sheet1
Excel 2003

In a Standard Module:
Rich (BB code):
Option Explicit
    
Sub exa()
Dim REX As Object
Dim wks As Worksheet
Dim rngData As Range
Dim Cell As Range
    
    Set REX = CreateObject("VBscript.RegExp")
    With REX
        .Global = True
        .IgnoreCase = False
        .Pattern = "[ACDRUVQ]"
        
        Set wks = ThisWorkbook.Worksheets("Sheet1")
        With wks
            Set rngData = Range(.Cells(2, "E"), .Cells(.Rows.Count, "E").End(xlUp))
        End With
        
        For Each Cell In rngData
            If .Test(Cell.Value) Then
                Cell.Offset(, 1).Value = .Replace(Cell.Value, vbNullString)
            End If
        Next
    End With
End Sub
Hope that helps,

Mark
 
Upvote 0

Forum statistics

Threads
1,224,537
Messages
6,179,408
Members
452,912
Latest member
alicemil

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