Delete and replace character without using helper cells

abdo meghari

Active Member
Joined
Aug 3, 2021
Messages
465
Office Version
  1. 2019
Hi
I have many items are existed in the last item should be delete and replace for the others for instance any word contains JA or JAPAN then should be JAP
and if there items contain THA or TH or THAILAND then should convert to THI and if I have IND or INDONESIA then should convert to INDO . so I have about 1500 rows for the items
TIRES.xlsm
ABCD
1ITEMBRANDQTYBALANCE
21BS 1200R20 18PR G580 TCF JA1,147.00791.00
32BS 13R22.5 R187 JAP60.00-
43BS 315/80R22.5 R184 THA98.00200.00
54BS 315/80R22.5 G580 JAPAN20.00-
65BS 1400R20 VSJ TCF THI141.00-
76BS 1200R24 G580 JAP194.00100.00
87BS 385/65R22.5 R164 INDO 70.00-
98BS 385/65R22.5 R164 THI200.00100.00
109BS 1200R24 22PR G582 IND100.00100.00
1110BS 265/70R16 D840 INDONESIA40.0050.00
1211BS 205R16C D840 THAILAND40.0050.00
1312BS 195/65R15 EP150 TH50.00-
1413BS 205/70R15C R623 THI200.00360.00
1514BS 215/70R15C R623 THI100.00-
1615BS 175/70R13 EP150 THI20.00-
1716BS 235/55R17 T005 THI40.00-
1817BS 225/70R16 H005 JAP150.00-
1918BS 255/70R16 H005 JAP95.00-
DATA



RESULT

TIRES.xlsm
ABCD
1ITEMBRANDQTYBALANCE
21BS 1200R20 18PR G580 TCF JAP1,147.00791.00
32BS 13R22.5 R187 JAP60.00-
43BS 315/80R22.5 R184 THI98.00200.00
54BS 315/80R22.5 G580 JAP20.00-
65BS 1400R20 VSJ TCF THI141.00-
76BS 1200R24 G580 JAP194.00100.00
87BS 385/65R22.5 R164 INDO 70.00-
98BS 385/65R22.5 R164 THI200.00100.00
109BS 1200R24 22PR G582 INDO100.00100.00
1110BS 265/70R16 D840 INDO40.0050.00
1211BS 205R16C D840 THI40.0050.00
1312BS 195/65R15 EP150 THI50.00-
1413BS 205/70R15C R623 THI200.00360.00
1514BS 215/70R15C R623 THI100.00-
1615BS 175/70R13 EP150 THI20.00-
1716BS 235/55R17 T005 THI40.00-
1817BS 225/70R16 H005 JAP150.00-
1918BS 255/70R16 H005 JAP95.00-
DATA
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
How about this

VBA Code:
Sub ChangeName()

    Dim arr, i As Long, p As Long, str As String
    
    arr = Range("B2:B" & Cells(Rows.Count, 2).End(xlUp).Row)
    For i = 1 To UBound(arr)
        p = InStrRev(arr(i, 1), " ")
        str = Mid(arr(i, 1), p + 1)
            Select Case str
                Case Is = "JA", "JAPAN"
                    arr(i, 1) = Replace(arr(i, 1), str, "JAP")
                Case Is = "THA", "TH", "THAILAND"
                    arr(i, 1) = Replace(arr(i, 1), str, "THI")
                Case Is = "IND", "INDONESIA"
                    arr(i, 1) = Replace(arr(i, 1), str, "INDO")
            End Select
    Next
    Range("B2").Resize(UBound(arr)) = arr
    
End Sub
 
Upvote 0
Or simple like:

VBA Code:
Sub jec()
 With Range("B2", Range("B" & Rows.Count).End(xlUp))
   .Replace "JA*", "JAP", 2
   .Replace "TH*", "THI", 2
   .Replace "IND*", "INDO", 2
 End With
End Sub
 
Upvote 0
Solution
@JEC gives you a good solution and you are worried about a new member missing your profile details. I don't get it...
 
Upvote 0
@JEC gives you a good solution and you are worried about a new member missing your profile details. I don't get it...
take it easy . I'm still test it . and just answer one by one .
thanks for your code
 
Upvote 0
take it easy . I'm still test it . and just answer one by one .
thanks for your code
Perhaps, it just seems like wasted keystrokes. Thanks for the feedback, we were all happy to help.
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,961
Latest member
nzskater

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