Question: This is the question. It works in excel. Using control and looping structures, I'm trying to reduce the number of code. Function LowerSpeed(VAl1 As Integer)
This is the question. It works in excel. Using control and looping structures, I'm trying to reduce the number of code.
Function LowerSpeed(VAl1 As Integer) LowerSpeed = VAl1 - 5 End Function
Function UpperSpeed(VAl2 As Integer) UpperSpeed = VAl2 + 5 End Function
Sub teslaAutoTest()
MsgBox "This sheet records test results auto pilot", vbOKCancel, "tesla test"
'Declare my input values Dim Reading1 As Integer Dim Speed1 As Integer Dim Reading2 As Integer Dim Speed2 As Integer Dim Reading3 As Integer Dim Speed3 As Integer
Dim cell As Range
'input your sensor values Reading1 = InputBox("Enter distance in m") Speed1 = InputBox("Enter Speed 1 in Km/hr") Reading2 = InputBox("Enter distance in m") Speed2 = InputBox("Enter Speed 2 in Km/hr") Reading3 = InputBox("Enter distance in m") Speed3 = InputBox("Enter Speed 3 in Km/hr")
Application.Range("C16").Value = Reading1 Application.Range("E16").Value = Speed1 Application.Range("G20").Value = Reading2 Application.Range("D16").Value = Application.Range("H9") Application.Range("F16").Value = LowerSpeed(Application.Range("E16").Value) Application.Range("G16").Value = UpperSpeed(Application.Range("E16").Value)
Application.Range("C17").Value = Reading2 Application.Range("E17").Value = Speed2 Application.Range("G20").Value = Reading2 Application.Range("D17").Value = Application.Range("H9") Application.Range("F17").Value = LowerSpeed(Application.Range("E17").Value) Application.Range("G17").Value = UpperSpeed(Application.Range("E16").Value)
Application.Range("C18").Value = Reading3 Application.Range("E18").Value = Speed3 Application.Range("G20").Value = Reading3 Application.Range("D18").Value = Application.Range("H9") Application.Range("F18").Value = LowerSpeed(Application.Range("E18").Value) Application.Range("G18").Value = UpperSpeed(Application.Range("E16").Value)
End Sub
Sub Clear_Cells() Range("C16:C18").ClearContents Range("D16:D18").ClearContents Range("E16:E18").ClearContents Range("F16:F18").ClearContents Range("G16:G18").ClearContents
End Sub
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
