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 Feb 8th, 2006, 07:26 PM   #1
dcliffo
 
Join Date: Jun 2003
Location: Arizona
Posts: 125
Default Conditioally insert characters to beginning of cell

I have a column of Supplier IDs. Maximum number of characters is 9. If the supplier ID is not 9 characters long, it should have 0's placed in the front so that there are 9 characters. For example, Supplier ID is 487695. It should look like 000487695. I can get Excel to format the cells correctly by using the custom format. However, when I import into Access, it trims the 0's away even though the field is identified as text because the custom format does not actually change the "value" of the cell. It merely formats the cells.

How can I get this column to correctly import into Access from Excel?
dcliffo is offline   Reply With Quote
Old Feb 8th, 2006, 07:32 PM   #2
Oaktree
MrExcel MVP
 
Oaktree's Avatar
 
Join Date: Jun 2002
Location: Chicago, IL
Posts: 7,584
Default

In a new column, use =TEXT(A1,rept("0",9)) and copy down. Use this new column for your import.
__________________
"The greatest challenge to any thinker is stating the problem in a way that will allow a solution." Bertrand Russell
Oaktree is offline   Reply With Quote
Old Feb 8th, 2006, 08:17 PM   #3
dcliffo
 
Join Date: Jun 2003
Location: Arizona
Posts: 125
Default

Thanks so very much! I knew it was simple, but I would have spent hours trying to figure that out. Never used rept before!
dcliffo is offline   Reply With Quote
Old Feb 8th, 2006, 08:33 PM   #4
Barry Katcher
 
Barry Katcher's Avatar
 
Join Date: Feb 2002
Location: Dog Beach, Florida. Yeaahh!
Posts: 4,018
Default

If you suffer from a mild case of Redundantbracketphobia, you can also try:

=TEXT(A1,"000000000")


__________________
Barry-

Photo Restoration/Enhancement

http://www.smiledogproductions.com
click below for detour

Barry Katcher is offline   Reply With Quote
Old Sep 1st, 2008, 10:17 PM   #5
deepakgoyal2005
 
Join Date: Sep 2008
Location: Pune, India
Posts: 25
Default Conditionally insert characters to beginning of cell

What if i have a case like i need to extend my TEXT data to a particular length :

E.g. I have entries like -

AAA
BBBB
CCCCC

And i want -
AAA@@
BBBB@
CCCCC

Such that there are same number of characters in each cell in a column.
Please provide a solution ?
deepakgoyal2005 is offline   Reply With Quote
Old Sep 1st, 2008, 10:21 PM   #6
PA HS Teacher
 
PA HS Teacher's Avatar
 
Join Date: Jul 2004
Location: Rochester, NY
Posts: 2,794
Default Re: Conditioally insert characters to beginning of cell

How about:
=A1&REPT("@",MAX(5-LEN(A1),0))
__________________
Recent Draftee
www.mrexcel.com/board2/viewtopic.php?t=199272
Recently came across a Free 1 GB Storage/File Sharing Site www.box.net
PA HS Teacher is offline   Reply With Quote
Old Sep 1st, 2008, 10:27 PM   #7
deepakgoyal2005
 
Join Date: Sep 2008
Location: Pune, India
Posts: 25
Default Re: Conditioally insert characters to beginning of cell

Thanks Dude...

That solved my problemmmm
deepakgoyal2005 is offline   Reply With Quote
Old Sep 2nd, 2008, 02:29 AM   #8
brockk
 
brockk's Avatar
 
Join Date: Jul 2006
Posts: 104
Default Re: Conditioally insert characters to beginning of cell

Quote:
Originally Posted by PA HS Teacher View Post
How about:
=A1&REPT("@",MAX(5-LEN(A1),0))
You probably want to refrase the formula cause when I tried it out, it works perfectly with the only exception that it completed it at the END of the cell and not the beginning as the op was requesting.
brockk is offline   Reply With Quote
Old Sep 2nd, 2008, 02:33 AM   #9
mikerickson
MrExcel MVP
 
mikerickson's Avatar
 
Join Date: Jan 2007
Location: Davis CA
Posts: 9,902
Default Re: Conditioally insert characters to beginning of cell

How about =LEFT(A1&"@@@@@@@@@",9)
mikerickson is offline   Reply With Quote
Old Sep 2nd, 2008, 02:50 AM   #10
brockk
 
brockk's Avatar
 
Join Date: Jul 2006
Posts: 104
Default Re: Conditioally insert characters to beginning of cell

Quote:
Originally Posted by mikerickson View Post
How about =LEFT(A1&"@@@@@@@@@",9)
Hi mikerickson.

Unfortunately that too completed towards the end and not the beginning. I guess when its a variable, its not as simple as it sounds to actually have it complete from the beginning.
brockk 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 +1. The time now is 05:20 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2010 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