Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Any corrections on the code would help. This is vba in excel. Function Da(k As _

ID: 672572 • Letter: A

Question

Any corrections on the code would help. This is vba in excel.

Function Da(k As ____, tau As ____) As Variant
'k= time scale, tau = residence time, Da = Damkohler number

Da = k * tau

End Function

Sub Damkohler()
Dim a As Variant
Dim b As Variant
Dim c As Variant
Dim i As Integer

a = 2 * Cells(1, 1).Value
b = Cells(2, 1).Value

If IsNumeric(a) And IsNumeric(b) And a > 0 And b > 0 Then
b = Da(a, b)
Cells(3, 1).Value = c
Cells(3, 3).Value = "NO"
Else

MsgBox ("Invalid Input")
Cells(3, 1).Value = "Error"
Cells(5, 3).Value = "YES"
i = i + 2
End If

End Sub

1. Fill in the blanks for the first line of code NOTE: Both lines can will use the same datatype

2. What is the final value of the variable c?

3. What is the final value of cell (3,1)

4. What is the initial value of the variable i?

NOTE: Whenever asked for the initial value of a variable - it will be the first assignment to that variable

5. What is the final value of the variable i?

Sub superman()

Dim a As Single

Dim b As Single

Dim c As Single

Dim i as Integer

b = 2 + Cells (1,1).Value

For i = 1 to 5 Step 2

c = a + b

Cells(i, b + 1).Value = c

Next i

Cells(3,3).Value = i - 7

If b = c Then

Cells(2,5).Value = 2

Else

Cells(2,5). Value = 3

End If

End Sub

1. What is the initial value of the variable b?

2. How many times does the for loop run?

3. What is the final value of the cell (3,3)?

4. What is the final value of the cell (2,5)?

5. What is the final value of the cell (5,3)?

R1C1 2 4 2 YES NO

Explanation / Answer

2) undefined c is not assigned to anything in the code

3) It will be Error. if condition of the code is not met hence else part will be executed.

4) It will be 0.

5) It will be 2. i=i+2 will be executed in else part.

1) Initial value of b will be 2.

2) loop will run for 3 times.

3) final value of b will be i-7 = 7-7 =0

4) Final value of cell (2,5) will be 2.

5) It will also be 2 as it will get the value of c becuase of this equation

Cells(i, b + 1).Value = c

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote