How would I output my specific times in column A starting with cell A3 Also Need
ID: 3793365 • Letter: H
Question
How would I output my specific times in column A starting with cell A3
Also Need to output y values in column C starting with C3
and X values column B starting at B3
Sub problem2()
Dim x0 As Integer, v0 As Integer, theta As Integer, g As Integer, t As Double, y0 As Integer Dim x As Double, y As Double
x0 = Range("F2").Value
y0 = Range("F3").Value
v0 = Range("F4").Value
theta = Range("F5").Value
g = -9.81
x = x0 + v0 * Cos(theta * (3.14159 / 180)) * t
y = y0 + v0 * Sin(theta * (3.14159 / 180)) * t + 0.5 * g * t ^ 2
Cells(2, 1) = 0
Cells(2, 2) = x
Cells(2, 3) = y
Do While (y > 0)
y = y0 + v0 * Sin(theta * (3.14159 / 180)) * t + (0.5 * g * t ^ 2) t = t + 0.1
If y > 0 Then x = x0 + v0 * Cos(theta * (3.14159 / 180)) * t
End If
Loop
End Sub
Explanation / Answer
'This syntax may help you to get the output in a specified range
'The worksheet has a Range property which you can use to access cells in VBA.
ThisWorkbook.Worksheets("sheet1").Range("A3") = t
ThisWorkbook.Worksheets("sheet1").Range("B3") = x
ThisWorkbook.Worksheets("sheet1").Range("C3") = y
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.