Converting units

StevenData

New Member
Joined
Mar 23, 2002
Messages
10
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
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,205
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top