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

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
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,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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