![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Posts: 12
|
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 ] |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
|
Well first off, you can replace all those X- replaces with just one. Search for the hyphen and leave the replace with blank.
As for the leading zero, do all tthe items have a leading zero or can there be another number there?
__________________
Veni, Vidi, Velcro - I came, I saw, I stuck around Taxation WITH representation ain't so hot either |
|
|
|
|
|
#3 |
|
New Member
Join Date: Mar 2002
Posts: 12
|
No, all the items do not have a leading zero.
The leading position can be any number between 0 and 9. [ This Message was edited by: harrysolomon on 2002-03-07 10:01 ] |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
|
Okay, are all the numbers the same length?
__________________
Veni, Vidi, Velcro - I came, I saw, I stuck around Taxation WITH representation ain't so hot either |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
|
I'm going to assume the numbers are all the same length. Search for the hyphen and replace with nothing. then format your cells with the custom format 000000000000. (that's 12 zeros)
Should fix you up
__________________
Veni, Vidi, Velcro - I came, I saw, I stuck around Taxation WITH representation ain't so hot either |
|
|
|
|
|
#6 |
|
New Member
Join Date: Mar 2002
Posts: 12
|
First of all, Yes the numbers are always 12 characters.
Second, your solution works perfectly. Thanks for your help! |
|
|
|
|
|
#7 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
Quote:
[ This Message was edited by: Mark W. on 2002-03-07 11:31 ] |
|
|
|
|
|
|
#8 | |
|
Board Regular
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
|
Quote:
__________________
Veni, Vidi, Velcro - I came, I saw, I stuck around Taxation WITH representation ain't so hot either |
|
|
|
|
|
|
#9 | |
|
Board Regular
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
|
Quote:
__________________
Veni, Vidi, Velcro - I came, I saw, I stuck around Taxation WITH representation ain't so hot either |
|
|
|
|
|
|
#10 |
|
New Member
Join Date: Mar 2002
Posts: 12
|
Ultimately, the spreadsheet is going to be saved as a *.prn file which will then be used as a COBOL sequential file. I'm writing a report which will read this UPC# and use it to test for other values. My original goal here was to be able to convert a UPC such
as "0-7567-82144-2-4" to "075678214424". |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|