{"id":10191,"date":"2022-06-27T14:50:29","date_gmt":"2022-06-27T14:50:29","guid":{"rendered":"https:\/\/officetuts.net\/excel\/?p=10191"},"modified":"2024-03-26T12:56:35","modified_gmt":"2024-03-26T12:56:35","slug":"diameter-formula","status":"publish","type":"post","link":"https:\/\/officetuts.net\/excel\/examples\/diameter-formula\/","title":{"rendered":"Diameter Formula in Excel"},"content":{"rendered":"\n

The diameter of a circle or a sphere is the length of the straight line connecting the center of the circle or sphere with two points on its perimeter or surface.<\/p>\n\n\n\n

We can construct formulas in Excel to calculate the diameter if any of the following is known: radius of the circle or sphere, circumference of the circle, area of the circle, or volume of the sphere.<\/p>\n\n\n\n

In this tutorial, we will learn how to create Excel formulas we can create to calculate the diameter given different situations.<\/p>\n\n\n\n

The Radius of a Circle or Sphere Is Known<\/h2>\n\n\n\n

Radius<\/strong> is the length of the line segment between the center and circumference of a circle or sphere. The diameter<\/strong> is twice the length of the radius.<\/p>\n\n\n\n

We use the following dataset with radiuses in column A to compute the diameter values in column B:<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

Use the PRODUCT function<\/h3>\n\n\n\n

We use the following steps:<\/p>\n\n\n\n

    \n
  1. Select cell B2 and enter the formula =PRODUCT(A2,2) as follows:<\/li>\n<\/ol>\n\n\n\n
    \"\"<\/figure>\n\n\n\n
      \n
    1. Press Enter key and double-click or drag down the fill handle to copy the formula down the column:<\/li>\n<\/ol>\n\n\n\n
      \"\"<\/figure>\n\n\n\n

      Explanation of the formula<\/strong><\/p>\n\n\n\n

      =PRODUCT(A2,2)<\/code><\/pre>\n\n\n\n

      The PRODUCT<\/strong> function multiplies all the numbers given as arguments. In this case, the function multiplied the radius values in column A with value 2 and returned diameter values in column B.<\/p>\n\n\n\n

      Use User Defined Function (UDF)<\/h3>\n\n\n\n

      Let’s create a User Defined Function<\/strong> in Excel VBA and use it to calculate the diameter.<\/p>\n\n\n\n

      We use the following steps:<\/p>\n\n\n\n

        \n
      1. In the active worksheet, press Alt + F11<\/strong> to open the Visual Basic Editor<\/strong>.<\/li>\n\n\n\n
      2. In the Project Window<\/strong> right-click the workbook and ins<\/strong>ert a new module<\/strong>:<\/li>\n<\/ol>\n\n\n\n
        \"\"<\/figure>\n\n\n\n
          \n
        1. In the new module type in the following code:<\/li>\n<\/ol>\n\n\n\n
          Function RADIUStoDIAMETER(RADIUS As Long) As Long\n    RADIUStoDIAMETER = WorksheetFunction.Product(RADIUS * 2)\nEnd Function\n<\/code><\/pre>\n\n\n\n
            \n
          1. Save the function procedure.<\/li>\n\n\n\n
          2. Save the workbook as a macro-enabled workbook<\/strong>.<\/li>\n\n\n\n
          3. Press Alt + F11<\/strong> to switch back to the active worksheet.<\/li>\n\n\n\n
          4. Select cell B2 and type in the formula =RADIUStoDIAMETER(A2) as follows:<\/li>\n<\/ol>\n\n\n\n
            \"\"<\/figure>\n\n\n\n

            We may have noticed that immediately we begin typing in the formula, our UDF appears in the list of the other Excel functions:<\/p>\n\n\n\n

            \"\"<\/figure>\n\n\n\n

            We can double-click it or press the tab key to enter it instead of typing it in. This saves time.<\/p>\n\n\n\n

              \n
            1. Press the Enter key and double-click or drag down the fill handle to copy the formula down the column:<\/li>\n<\/ol>\n\n\n\n
              \"\"<\/figure>\n\n\n\n

              Explanation of the User-Defined Function<\/strong><\/p>\n\n\n\n