Automated Edit/Replace

jbfrank

Active Member
Joined
Oct 13, 2003
Messages
290
I'm trying to find a way to automate the Edit --> Replace function in Excel.

Every morning, I pull a report containing well over a hundred different SKU's. Each SKU has it's own suffix code. For example, let's say a package of golf balls has 35600 as the SKU. At the end of that SKU, we might have a /05 to designate pink golf balls rather than white (which would have an /01. With the suffix, the entire SKU would look like this: 35600/01.

I would like to remove the /01 from each of the SKU's. If I create a list in Excel of all of the slash codes available, how do I get the Edit --> Replace function to automate so that every slash code in that list is removed from a set column?

Thank you in advance for your help.
 
Hi jbfrank,

in column G are your SKUs and in Range H1:H150 are your suffix codes....

Please try this macro in a test file:

Code:
Option Explicit

Sub test()
    Dim lngI    As Long
    Dim lngLast As Long
    Dim rng     As Range

 Application.ScreenUpdating = False
 lngLast = ActiveSheet.Range("G65536").End(xlUp).Row
 
 For Each rng In ActiveSheet.Range("H1:H150")
    For lngI = 1 To lngLast
        If rng.Value = Right(Cells(lngI, 7), Len(rng.Value)) Then
          With Cells(lngI, 7)
            .Value = Left(.Value, Len(.Value) - Len(rng.Value))
            .Interior.ColorIndex = 3
          End With
        End If
    Next lngI
 Next rng
 Application.ScreenUpdating = True
 MsgBox "Ready!"
End Sub
 
Upvote 0

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,215,506
Messages
6,125,189
Members
449,213
Latest member
Kirbito

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