Convert Fahrenheit to Celsius with VBA - Printable Version +- QP School (https://qomplainerzschool.lima-city.de) +-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3) +--- Forum: Excel VBA Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=48) +--- Thread: Convert Fahrenheit to Celsius with VBA (/showthread.php?tid=5240) |
Convert Fahrenheit to Celsius with VBA - Qomplainerz - 07-27-2023 Example: Sub ConvertToFahrenheit() Dim fahrenheitTemp As Double Dim celsiusTemp As Double fahrenheitTemp = 68 celsiusTemp = (fahrenheitTemp - 32) * 5 / 9 MsgBox fahrenheitTemp & " degrees Fahrenheit is equal to " & celsiusTemp & " degrees Celsius." End Sub Explanation: This code defines a subroutine named ConvertToFahrenheit. It declares two variables fahrenheitTemp and celsiusTemp to store temperatures in Fahrenheit and Celsius, respectively. It sets the value of fahrenheitTemp to 68. The temperature in Fahrenheit is converted to Celsius using the formula (Fahrenheit - 32) * 5 / 9. The converted temperature is then displayed in a message box. The formula (Fahrenheit - 32) * 5 / 9 is used to convert temperatures from Fahrenheit to Celsius. The MsgBox function displays the converted temperature in a message box. |