MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Mar 7th, 2002, 10:28 AM   #1
harrysolomon
New Member
 
Join Date: Mar 2002
Posts: 12
Default

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 ]
harrysolomon is offline   Reply With Quote
Old Mar 7th, 2002, 10:53 AM   #2
Steve Hartman
Board Regular
 
Steve Hartman's Avatar
 
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
Default

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
Steve Hartman is offline   Reply With Quote
Old Mar 7th, 2002, 11:00 AM   #3
harrysolomon
New Member
 
Join Date: Mar 2002
Posts: 12
Default

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 ]
harrysolomon is offline   Reply With Quote
Old Mar 7th, 2002, 11:05 AM   #4
Steve Hartman
Board Regular
 
Steve Hartman's Avatar
 
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
Default

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
Steve Hartman is offline   Reply With Quote
Old Mar 7th, 2002, 11:46 AM   #5
Steve Hartman
Board Regular
 
Steve Hartman's Avatar
 
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
Default

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
Steve Hartman is offline   Reply With Quote
Old Mar 7th, 2002, 12:16 PM   #6
harrysolomon
New Member
 
Join Date: Mar 2002
Posts: 12
Default

First of all, Yes the numbers are always 12 characters.

Second, your solution works perfectly.

Thanks for your help!



harrysolomon is offline   Reply With Quote
Old Mar 7th, 2002, 12:30 PM   #7
Mark W.
MrExcel MVP
 
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
Default

Quote:
On 2002-03-07 11:16, harrysolomon wrote:
First of all, Yes the numbers are always 12 characters.

Second, your solution works perfectly.

Thanks for your help!

However, Steve's recommendation will convert your bar code to a numeric data type that is stored without the leading zero. Formatting only governs the display of the value. If you intend to search or conditionally test for "075678214424" you won't find it. Because of this and because you won't be performing arithmetic operations on these values I strongly suggest that you format the bar codes as Text before you replace the hyphens! Doing so will preserve the leading zeroes as well as the textual nature of your bar code.

[ This Message was edited by: Mark W. on 2002-03-07 11:31 ]
Mark W. is offline   Reply With Quote
Old Mar 7th, 2002, 12:35 PM   #8
Steve Hartman
Board Regular
 
Steve Hartman's Avatar
 
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
Default

Quote:
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.
He's already tried formatting as text. I did also, and removing the hyphens drops the leading zero.
__________________
Veni, Vidi, Velcro - I came, I saw, I stuck around

Taxation WITH representation ain't so hot either
Steve Hartman is offline   Reply With Quote
Old Mar 7th, 2002, 12:35 PM   #9
Steve Hartman
Board Regular
 
Steve Hartman's Avatar
 
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
Default

Quote:
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.
He's already tried formatting as text. I did also, and removing the hyphens drops the leading zero.
__________________
Veni, Vidi, Velcro - I came, I saw, I stuck around

Taxation WITH representation ain't so hot either
Steve Hartman is offline   Reply With Quote
Old Mar 7th, 2002, 12:37 PM   #10
harrysolomon
New Member
 
Join Date: Mar 2002
Posts: 12
Default

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".

harrysolomon is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 03:25 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes