कन्वर्ट पैर और इंच दशमलव पैर में - एक्सेल युक्तियाँ

विषय - सूची

अद्यतन मार्च 2017: डैन एशबी के पास एक बेहतर पैर और इंच-इन-एक्सेल फ़ंक्शन उपलब्ध है।

मेरे पास 12 '6 7/8 "के प्रारूप में लंबाई के एक स्तंभ के साथ एक एक्सेल स्प्रेडशीट है। मैं इसे दशमलव पैरों में बदलने के लिए एक्सेल का उपयोग कैसे कर सकता हूं? मैं कॉलम को दो भागों में विभाजित नहीं करना चाहता। फिर, कैसे क्या मैं वापस पैर और इंच को एक्सेल में बदल सकता हूँ?

नीचे दिखाए गए कस्टम फ़ंक्शन फीट () आपके द्वारा वर्णित प्रारूप में एक टेक्स्ट फ़ील्ड लेगा और इसे दशमलव पैरों में बदल देगा।

कस्टम फ़ंक्शन लेनटेक्स्ट पैरों की एक दशमलव संख्या को एक पाठ क्षेत्र में परिवर्तित करेगा, जो पैरों, इंच और भिन्नात्मक इंच को निकटतम 1/32 में दिखाएगा "।

कस्टम फ़ंक्शन में प्रवेश करने के लिए,

  • VB संपादक की शुरुआत F-F11 से करें।
  • सम्मिलित करें> मॉड्यूल।
  • सम्मिलित करें> प्रक्रिया।
  • प्रक्रिया के नाम के रूप में पैर टाइप करें और इंगित करें कि यह एक फ़ंक्शन है।
  • फिर, निम्न कोड की प्रतिलिपि बनाएँ:
Public Function feet(LenString As String) Dim FootSign As Integer Dim InchSign As Integer Dim SpaceSign As Integer Dim FracSign As Integer Dim InchString As String Dim Word2 As String ' Copyright 1999, 2005.com LenString = Application.WorksheetFunction.Trim(LenString) 'The find function returns an error when the target is not found 'Resume Next will prevent VBA from halting execution. On Error Resume Next FootSign = Application.WorksheetFunction.Find("'", LenString) If IsEmpty(FootSign) Or FootSign = 0 Then ' There are no feet in this expression feet = 0 FootSign = 0 Else feet = Val(Left(LenString, FootSign - 1)) End If ' Handle the case where the foot sign is the last character If Len(LenString) = FootSign Then Exit Function ' Isolate the inch portion of the string InchString = Application.WorksheetFunction.Trim(Mid(LenString, FootSign + 1)) ' Strip off the inch sign, if there is one InchSign = Application.WorksheetFunction.Find("""", InchString) If Not IsEmpty(InchSign) Or InchSign = 0 Then InchString = Application.WorksheetFunction.Trim(Left(InchString, InchSign - 1)) End If ' Do we have two words left, or one? SpaceSign = Application.WorksheetFunction.Find(" ", InchString) If IsEmpty(SpaceSign) Or SpaceSign = 0 Then ' There is only one word here. Is it inches or a fraction? FracSign = Application.WorksheetFunction.Find("/", InchString) If IsEmpty(FracSign) Or FracSign = 0 Then 'This word is inches feet = feet + Val(InchString) / 12 Else ' This word is fractional inches feet = feet + (Val(Left(InchString, FracSign - 1)) / Val(Mid(InchString, FracSign + 1))) / 12 End If Else ' There are two words here. First word is inches feet = feet + Val(Left(InchString, SpaceSign - 1)) / 12 ' Second word is fractional inches Word2 = Mid(InchString, SpaceSign + 1) FracSign = Application.WorksheetFunction.Find("/", Word2) If IsEmpty(FracSign) Or FracSign = 0 Then ' Return an error feet = "VALUE!" Else If FracSign = 0 Then feet = "VALUE!" Else feet = feet + (Val(Left(Word2, FracSign - 1)) / Val(Mid(Word2, FracSign + 1))) / 12 End If End If End If End Function

LenText नामक फ़ंक्शन के लिए दोहराएं। इस कोड का उपयोग करें:

Public Function LenText(FeetIn As Double) ' This function will change a decimal number of feet to the text string ' representation of feet, inches, and fractional inches. ' It will round the fractional inches to the nearest 1/x where x is the denominator. ' Copyright 1999.com Denominator = 32 ' must be 2, 4, 8, 16, 32, 64, 128, etc. NbrFeet = Fix(FeetIn) InchIn = (FeetIn - NbrFeet) * 12 NbrInches = Fix(InchIn) FracIn = (InchIn - NbrInches) * Denominator Numerator = Application.WorksheetFunction.Round(FracIn, 0) If Numerator = 0 Then FracText = "" ElseIf InchIn>= (11 + (31.4999999 / 32)) Then NbrFeet = NbrFeet + 1 NbrInches = 0 FracText = "" ElseIf Numerator = Denominator Then NbrInches = NbrInches + 1 FracText = "" Else Do ' If the numerator is even, divide both numerator and divisor by 2 If Numerator = Application.WorksheetFunction.Even(Numerator) Then Numerator = Numerator / 2 Denominator = Denominator / 2 Else FracText = " " & Numerator & "/" & Denominator Exit Do End If Loop End If LenText = NbrFeet & "' " & NbrInches & FracText & """" End Function
बदलना पैर और इंच दशमलव दशमलव में

कॉलम A मूल पाठ दिखाता है। कॉलम बी सही ढंग से पैर, इंच, और / या आंशिक इंच वाले किसी भी मूल्य को पैरों में परिवर्तित करता है।

ध्यान दें कि यदि आप पैर के संकेत को शामिल नहीं करते हैं, तो मान इंच माना जाता है। (पंक्ति १२)। यदि इंच का भिन्नात्मक भाग मान्य नहीं है, तो मान! लौटा है (पंक्ति 13)।

अपडेट: कैनसस सिटी के डेल रिचमंड का धन्यवाद जिन्होंने 1 अक्टूबर 12 इंच के उत्तर को रोकने के लिए अक्टूबर 2007 में एक अपडेट प्रदान किया था जब 1.999 से अधिक की संख्या फ़ंक्शन को पास की जाती है।

दिलचस्प लेख...