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 24th, 2002, 04:07 PM   #1
StevenData
New Member
 
Join Date: Mar 2002
Posts: 10
Default

Greetings,
I am trying to solve a simple problem using excel. I would like excel to convert the following numbers, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 2.10, 2.11 (in feet) into 2.0, 2.08, 2.17, 2.25, 2.33, 2.4, 2.5,2.6, 2.66,2.75,2.83,2.9, respectively. How do you think I should go about solving this problem. Can it be done with Macros with the least effort? I cannot use formulas or functions to do it since I will be dealing with multiple IF Then statements. I appreciate your help. Thank you.
Sincerely,
Steve
StevenData is offline   Reply With Quote
Old Mar 24th, 2002, 04:19 PM   #2
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,319
Default

Quote:
On 2002-03-24 15:07, StevenData wrote:
Greetings,
I am trying to solve a simple problem using excel. I would like excel to convert the following numbers, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 2.10, 2.11 (in feet) into 2.0, 2.08, 2.17, 2.25, 2.33, 2.4, 2.5,2.6, 2.66,2.75,2.83,2.9, respectively. How do you think I should go about solving this problem. Can it be done with Macros with the least effort? I cannot use formulas or functions to do it since I will be dealing with multiple IF Then statements. I appreciate your help. Thank you.
Sincerely,
Steve
Did you consider using the CONVERT worksheet function?

Aladin
Aladin Akyurek is offline   Reply With Quote
Old Mar 24th, 2002, 04:30 PM   #3
Jay Petrulis
MrExcel MVP
 
Jay Petrulis's Avatar
 
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
Default

Quote:
On 2002-03-24 15:07, StevenData wrote:
Greetings,
I am trying to solve a simple problem using excel. I would like excel to convert the following numbers, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 2.10, 2.11 (in feet) into 2.0, 2.08, 2.17, 2.25, 2.33, 2.4, 2.5,2.6, 2.66,2.75,2.83,2.9, respectively. How do you think I should go about solving this problem. Can it be done with Macros with the least effort? I cannot use formulas or functions to do it since I will be dealing with multiple IF Then statements. I appreciate your help. Thank you.
Sincerely,
Steve
Hi Steve,

If I am reading you correctly, your data says 2.3, but that really means 2 feet 3 inches. 2.11 is 2 feet 11 inches, right?

If your data is in A1:A12 try,

=INT(A1)+IF(ISERROR(FIND(".",A1,1)),0,RIGHT(A1,LEN(A1)-FIND(".",A1,1))/12)

and copy down the list.

The error checking is required because the FIND call throws an error at the integers.

HTH,
Jay

Edit: The above requires that your data range is text values. That way, there is a distinction between 2.1 and 2.10.

The code from DK doesn't handle the 2.10 and 2.11 properly. It can easily be adjusted, depending on some information needed from you (see last part of message). It's quick and prefereable to using another column. Yogi's reply is incorrect for all but 2.10 and 2.11.

Please let us know if your data is formatted so that 2.1 is clearly distinct from 2.10. This is the root cause of the troubles.

[ This Message was edited by: Jay Petrulis on 2002-03-24 21:59 ]
Jay Petrulis is offline   Reply With Quote
Old Mar 24th, 2002, 04:32 PM   #4
dk
MrExcel MVP
 
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 2,908
Default

If you want a macro to do this conversion on a range of cells then perhaps this will work:-

Code:
Sub ConvertFeetAndInches()
Dim cl As Range

For Each cl In Selection.Cells
    If IsNumeric(cl.Value) Then
        cl.Value = Format(Int(cl.Value) + (cl.Value - Int(cl.Value)) * 10 / 12, "#,##0.00")
    End If
Next
End Sub
Hope it helps,
D
dk is offline   Reply With Quote
Old Mar 24th, 2002, 04:39 PM   #5
Yogi Anand
MrExcel MVP
 
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
Default

Quote:
On 2002-03-24 15:07, StevenData wrote:
Greetings,
I am trying to solve a simple problem using excel. I would like excel to convert the following numbers, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 2.10, 2.11 (in feet) into 2.0, 2.08, 2.17, 2.25, 2.33, 2.4, 2.5,2.6, 2.66,2.75,2.83,2.9, respectively. How do you think I should go about solving this problem. Can it be done with Macros with the least effort? I cannot use formulas or functions to do it since I will be dealing with multiple IF Then statements. I appreciate your help. Thank you.
Sincerely,
Steve
Hi StevenData:
The following simple formula will do what you are looking for ...

if your entry with 2ft and 2digit inches is in B21 then decimal feet will be ...
=INT(B21)+RIGHT(B21,2)/12

so here is how your numbers workout using the above formula

2.1 2.01
2.2 2.02
2.3 2.03
2.4 2.03
2.5 2.04
2.6 2.05
2.7 2.06
2.8 2.07
2.9 2.08
2.10 2.83
2.11 2.92

HTH
Please post back if it works for you ... otherwise explain alittle further and let us 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 25th, 2002, 08:38 AM   #6
Yogi Anand
MrExcel MVP
 
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
Default

Hi Jay:
I just saw your posting ... you are right that my earlier post shows incorrect results for 2ft&in01 through 2ft&in09. I don't know why how I reported the results like that, the correct formula and the results are as follows:
2 ft&in.00 =INT(B21)+RIGHT(B21,2)/12
2 ft&in.01 2.08
2 ft&in.02 2.17
2 ft&in.03 2.25
2 ft&in.04 2.33
2 ft&in.05 2.42
2 ft&in.06 2.50
2 ft&in.07 2.58
2 ft&in.08 2.67
2 ft&in.09 2.75
2 ft&in.10 2.01
2 ft&in.11 2.92
2 ft&in.12 3.00

StevenData, please note that I have used two digit representation for inches -- otherwise you run into problems differentiating between 2.1 and 2.10

Sorry for the confusion in my earlier posting!

[ This Message was edited by: Yogi Anand on 2002-03-25 09:39 ]
Yogi Anand is offline   Reply With Quote
Old Mar 26th, 2002, 06:53 PM   #7
StevenData
New Member
 
Join Date: Mar 2002
Posts: 10
Default

Greetings,
Thank you so very much for your responses to my post.
The problem is actually more complicated and involves converting feet.feet to feet.inches for a range of values from 1 to 30. For instance, 2.1 (feet.feet) is approximately equal to 2.08 (feet.inches) and 2.10 (feet.feet, that is two feet and 0.10 feet) is a equal to 2.83(feet.inches, that is two feet and 83 inches). The real dilemma among others is the fact that 2.1 and 2.10 are the same numeric values but very different measurements.
My solution was that to isolate the decimal part of each value (in feet) and then convert them into inches by multiplying them by 10 (or 100 for .10 and .11) and then divide them by 12. The result in inchesthen can be added to their respective isolated digits. This is a small piece of code in C, but writing a macro using VB for it proved rather difficult.
I am trying some of the solutions you have provided, especially the macro posted by dk sounds promising. Further assistance will be deeply appreciated.

Thanks again,
Steve
StevenData 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 07:15 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