UPC Bar Code info in Excel

harrysolomon

New Member
Joined
Mar 6, 2002
Messages
25
I have a column which contains UPC Bar Code information, for example 0-7567-82144-2-4.
I need to remove the hyphens from the bar code info, while preserving the leading zero.
I wrote a macro to do this by using EDIT|REPLACE and replacing "0-" with "0", "1-" with "1" etc, up through "9-".
However this causes the leading zero to disappear. I've tried changing the format of the column prior to using EDIT|REPLACE but the zero is discarded no matter what format I use.
Can somebody please tell me how to accomplish
this?

Thanks
This message was edited by harrysolomon on 2002-03-07 09:29
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Yes, technically I could format the spreadsheet in the COBOL program. But
I was trying to get as much of the formatting
of the information as possible done before creating the *.prn file.
 
Upvote 0
So the question before the court is whether you want the UPC stored as a 12 character text entry, or whether the entries can be true numbers which are DISPLAYED as 12 digits regardless the the true number of digits.

When I send data to our COBOL machine, I have to change every to fixed length text. In this case, you would REPLACE the hyphen with a null (blank), then use =TEXT(a2,"000000000000") to convert the field to true text with 12 real characters; copy down the spreadsheet, then highlight the TEXT formulas, copy, and paste/special/values to remove the formulas. I usually overwrite the original data, but that is your choice.

When you remove the hypens, Excel sees the entry as a number. If numbers are what you want, as noted above you can create a custom format so that leading zeros are displayed even though they are not present in the number stored in the cell.
 
Upvote 0
Storing the UPC as a 12 character text entry
seems to work.
The solution I've settled on, is to select the column with the UPC data, replace the hyphens and then format the column as Custom '000000000000'.
This keeps the leading 0 in place, and it appears to work in the sequential file (I've defined the UPC field in the file as pic x(12)).
 
Upvote 0

Forum statistics

Threads
1,223,516
Messages
6,172,777
Members
452,477
Latest member
DigDug2024

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