### Introduction

###
**VBA code**

The code for this function is given below:

Option Explicit Function FrictionFactor(Roughness As Double, Diameter As Double, Velocity As Double, Viscosity As Double) '----------------------------------------------------------------------------- 'Calculates the friction factor of a pipe using Churchill's equation (1977). 'This equation is valid for all types of flows (from laminar to turbulent). 'Written Βy: Christos Samaras 'Date: 04/08/2011 'E-mail: xristos.samaras@gmail.com 'Site: http://www.myengineeringworld.net '----------------------------------------------------------------------------- 'Declaring the necessary variables. Dim Reynolds As Double Dim A As Double Dim B As Double 'Calculate the Reynolds number. Reynolds = (Diameter * Velocity) / Viscosity 'Calculate the intermediate variables A and B. A = ((2.457 * WorksheetFunction.Ln(1 / ((Roughness / (3.7 * Diameter)) + ((7 / Reynolds) ^ 0.9)))) ^ 16) B = (37530 / Reynolds) ^ 16 'Apply the equation. FrictionFactor = 8 * ((((8 / Reynolds) ^ 12) + ((A + B) ^ (-3 / 2))) ^ (1 / 12)) End Function

###
**Downloads**

The file can be opened with Excel 2007 or newer. Note that you should enable macros to use it.

**Did you like this post? If yes, then share it with your friends. Thank you!**