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 22nd, 2002, 11:31 AM   #1
dtaylor
Board Regular
 
Join Date: Mar 2002
Location: So Cal
Posts: 380
Default

each month i download text files off an aops mainframe system and then do calucations in access with the data. my prob is that when i export the data to excell the numbers do not convert to values (even in access they do not convert. If I try to force the format while importing the data to Access I lose everything in that column). Example..a cell that should read .10% reads just .10 and will not convert to a percentage. I have to manually do a values(trim()) formula to convert the cells to values. Is there a way to convert all the cells of a certain column to a value and apply a percentage format in VBA? Any help would be greatly appreciated! Thanks
dtaylor is offline   Reply With Quote
Old Mar 22nd, 2002, 12:06 PM   #2
Al Chara
MrExcel MVP
 
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
Default

The following code will convert all cells in Column A to values and then to percentages. You might only need the code to convert to a percentage.

Columns(1).NumberFormat = "0.00"
Columns(1).NumberFormat = "0%"
__________________
Kind regards,

Al Chara
Al Chara is offline   Reply With Quote
Old Mar 22nd, 2002, 12:33 PM   #3
dtaylor
Board Regular
 
Join Date: Mar 2002
Location: So Cal
Posts: 380
Default

thanks for the quick response, unfortunetley it did not work. to test the code i manually placed a .10 in the first cell of the column, ran the code and the number i manually typed changed to the correct format but the balance did not.
dtaylor is offline   Reply With Quote
Old Mar 22nd, 2002, 12:51 PM   #4
Al Chara
MrExcel MVP
 
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
Default

What do you mean by, "balance did not"?
If you activate one of the cells and click on Format,Cells,Number tab, what format is highlighted?
Al Chara is offline   Reply With Quote
Old Mar 22nd, 2002, 02:44 PM   #5
dtaylor
Board Regular
 
Join Date: Mar 2002
Location: So Cal
Posts: 380
Default

What I meant was that the data from the text file did not convert when applying the code. I tested it by manually placing a number in the first free cell of the problem column and then running the code (not every cell has an entry). The cell that I typed a number in converted to a percentage but the rest or "balance" did not. Under format cells the data type is reading as "General". I changed the type to percantage but nothing. What I do to get around this is an =Values(AO2) formula changing the cells in the column to a value (once I do this I am able to apply a percentage format), then copy/pastespecial the converted data and replaceing the bunk formated data. Do appreciate your help and I hope I was clear.
dtaylor is offline   Reply With Quote
Old Mar 22nd, 2002, 03:29 PM   #6
Jay Petrulis
MrExcel MVP
 
Jay Petrulis's Avatar
 
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
Default

Quote:
On 2002-03-22 13:44, dtaylor wrote:
What I meant was that the data from the text file did not convert when applying the code. I tested it by manually placing a number in the first free cell of the problem column and then running the code (not every cell has an entry). The cell that I typed a number in converted to a percentage but the rest or "balance" did not. Under format cells the data type is reading as "General". I changed the type to percantage but nothing. What I do to get around this is an =Values(AO2) formula changing the cells in the column to a value (once I do this I am able to apply a percentage format), then copy/pastespecial the converted data and replaceing the bunk formated data. Do appreciate your help and I hope I was clear.
1. Select an unused, blank cell and Copy it.
2. Highlight the column (selection, range, etc.) with the numbers Excel thinks is text.
3. Edit>PasteSpecial> and select the ADD radio button from the Operation area
4. Choose OK.

This should coerce your cells into numbers.

This can also be done in code.

HTH,
Jay
Jay Petrulis is offline   Reply With Quote
Old Mar 22nd, 2002, 03:30 PM   #7
Yogi Anand
MrExcel MVP
 
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
Default

Hi dtaylor:
It appears that when you are importing data into Excel, it is being formatted as text. So, this is what you want to do...
1) Let us say your imported data is in cells B2 through B6
2) Key in 1 in any cell, say D1
3) highlite D1 then EDIT|COPY
4) then highlite B2:B6 and EDIT|PASTE_SPECIAL|multiply
5) format B2:B6 as percentage
Your results should look like ...

original data
0.1
0.2
0.15
0.3
0.32

data after EDIT|PASTE_SPECIAL|multiply

10%
20%
15%
30%
32%

I hope this is what you wanted ... please post back if this works for you, otherwise explain it a little further and we will take it from there!


__________________
Regards!

Yogi Anand, D.Eng, P.E.
Energy Efficient Building Network LLC
www.energyefficientbuild.com
Yogi Anand is offline   Reply With Quote
Old Mar 22nd, 2002, 03:43 PM   #8
dtaylor
Board Regular
 
Join Date: Mar 2002
Location: So Cal
Posts: 380
Default

Great! Both worked and I cut out a step. Now can this be done in code? I am working with a huge amount of files and would like to add code to a template that takes care of this without doing any formulas or pastespecial?
Once again thanks for your help!

[ This Message was edited by: dtaylor on 2002-03-22 14:44 ]
dtaylor is offline   Reply With Quote
Old Mar 22nd, 2002, 03:53 PM   #9
Jay Petrulis
MrExcel MVP
 
Jay Petrulis's Avatar
 
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
Default

Hi,

Something like this should work...

---begin VBA---
Sub test()
Dim cell As Range

For Each cell In Selection
cell.Value = cell + 0
Next cell

End Sub
---end VBA---

HTH,
Jay
Jay Petrulis is offline   Reply With Quote
Old Mar 22nd, 2002, 04:11 PM   #10
dtaylor
Board Regular
 
Join Date: Mar 2002
Location: So Cal
Posts: 380
Default

thanks the code worked. true saviors to mankind! have a great weekend..
dtaylor 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 04:46 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