Trim numbers in a range of cells

Naxdk

New Member
Joined
Aug 15, 2017
Messages
5
I need help writing a formula or macro that can automatically trim numbers in an area of cells, ex A3 to A55, my knowledge about Excel is unfortunately not big enough so I hope some will help :)



The numbers come from a barcode scanner, they look like these examples:
30xx2200755, 30xx + 2200755 and 2201755, xx is entered as these numbers vary, it is 30xx and 30xx + that's needs to be removed.


It would be best with a formula to monitor the cells, but a macro that can do it with a single press can also be used :)


Hope there are some one who will help :)
 
Re: formula or macro help.

Do you want to return everything to the right of the "+" if there is one?

If so, one formula could be:

=0+RIGHT(SUBSTITUTE(A1,"+",REPT(" ",LEN(A1))),LEN(A1))

Or you can manually do a find replace; Find: *+ Replace: nothing

Or with code:

Code:
Columns("A").Replace What:="*+", Replacement:="", LookAt:=xlPart
 
Upvote 0

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Re: formula or macro help.

The numbers are scanned into the sheet mixed, some with 30xx+1234567, 30xx1234567 and some without any prefix(1234567), end result should be the 7 digits without any prefix in all cells.


Sorry if it is not clear enough in the first post.


Hope there is a solution :)
 
Upvote 0
Re: formula or macro help.

end result should be the 7 digits without any prefix in all cells.

If the part you want to retain is always 7 digits then you can use the RIGHT() function that has already been suggested. Although you might want to modify it slightly to coerce the result to a number:

=0+RIGHT(A1,7)
 
Upvote 0

Forum statistics

Threads
1,216,503
Messages
6,131,020
Members
449,615
Latest member
Nic0la

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