Drop everything after character ($)

BrutalDawg

New Member
Joined
Jun 10, 2015
Messages
41
I am still to find a one time solution to drop everything in column B that comes after the $.

For example, all of column be will have items such as abc123$$45@@ceb, def456$$25@@cab. I want to setup a rule where everything in column B would be limitted to abc123, def456, etc.

Currently I can just run a find a replace, or use the trim or left functions to put the content in another cell, but I am trying to find a way that I can apply this to the whole B column.

Currently the user is using a scanner to insert the data into column B, but the barcode contains additional information after the $ that is not required for this exercise.

Any ideas?

CurrentDesired
DateItemQuantityDateItemQuantity
5/25/20213103602$$5050(50)
44341​
3103602​
50(50)
5/25/2021DZ114363$$33(3)
44341​
DZ1143633(3)
5/25/2021DZ114364$$33(3)
44341​
DZ1143643(3)
5/25/2021DZ114367$$33(3)
44341​
DZ1143673(3)
5/25/2021DZ114369$$33(3)
44341​
DZ1143693(3)

As you can see from the example, our barcode contains itemnumber$$quantity, i would only like the item quantity in column B, ideally it could move quantity to column c but that is not required.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
How about a VBA solution that drops the string after the "$" as values are being entered into column B?
Would that be an acceptable solution?
 
Upvote 0
If you want result at same cell, you should use macro (Vba)
 
Upvote 0
If my approach is acceptable, to control it as the data is scanned/entered, then right-click on the sheet tab name at the bottom of the screen, select "View Code", and paste this code in the resulting VB Editor window.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim arr() As String

    If Target.CountLarge > 1 Then Exit Sub
    
    If Target.Column = 2 Then
        Application.EnableEvents = False
        arr = Split(Target.Value, "$")
        Target.NumberFormat = "@"
        Target = arr(0)
        Application.EnableEvents = True
    End If

End Sub
 
Upvote 0
Hello Joe,

You solution works great! Exactly what I was looking for.

One issue I am seeing now, is there is no VBA in an shared excel sheet because it is actually excel online, but I think with this just being a single user he should still be able to use it from his desktop app and share. Will update back.
 
Upvote 0
One issue I am seeing now, is there is no VBA in an shared excel sheet because it is actually excel online, but I think with this just being a single user he should still be able to use it from his desktop app and share. Will update back.
Yes. VBA should be operational if the download it to their desktop.

Just note that any solution that you want to handle it right in column B (without having to add new columns or do stuff manually) will require VBA.
 
Upvote 0

Forum statistics

Threads
1,215,004
Messages
6,122,656
Members
449,091
Latest member
peppernaut

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