#### Km to miles and miles to km converter

In this Excel tutorial lesson, you will learn how to convert km to miles and miles to km using the Microsoft Excel application.

## Method 1. Convert using simple multiplication or division

1.609 is the crucial number here. To convert km to miles, you need to just divide by 1.609. Similarly, to convert miles to km, you need to multiply by 1.609.

## Method 2. Conversion using CONVERT Excel function

The CONVERT function automatically converts the value based on the specified input and output units, which eliminates the need for a separate conversion factor or formula. This method is more efficient and less prone to errors, as the conversion is handled by the built-in function in Excel.

=CONVERT(cell,”unit1″,”unit2″)

## Method 3. Convert using VBA code

This VBA code will ask you how many km you want to convert to miles:

```Function ConvertKilometersToMiles(kilometers As Double) As Double ConvertKilometersToMiles = kilometers * 0.621371 End Function Sub ConvertKilometersToMilesMain() Dim kilometers As Double Dim miles As Double kilometers = InputBox("Enter the number of kilometers to convert to miles:") If IsNumeric(kilometers) Then miles = ConvertKilometersToMiles(kilometers) MsgBox kilometers & " kilometers is equal to " & miles & " miles", vbInformation, "Kilometers to Miles Conversion" Else MsgBox "Invalid input! Please enter a valid number.", vbExclamation, "Error" End If End Sub```

The custom functions in the Visual Basic module handle the conversion by applying the appropriate formula, which makes the conversion process easier and more efficient. This method also allows you to modify the conversion formulas if needed, by simply editing the code in the module.