Understanding Sheet Access and For Loops Open a worksheet and type = rand ( ) into cell A:1. Here, rand ( ) is an RN generator; it will generate numbers between 0 and 1. Press the F9 key to see it...


Understanding Sheet Access and For Loops Open a worksheet and type = rand ( ) into cell A:1. Here, rand ( ) is an


RN generator; it will generate numbers between 0 and 1.


Press the F9 key to see it work.


Set up a simple VBA program that will access rand


( ) 1000 times and then compute and report the average


value.


Can this same task be accomplished without using


VBA? If no, explain why not


Option Explicit


Public Sub Simple_Addition()


Dim x As Double


Dim y As Double


Dim z As Double


'By Reference


x = 1


y = 2


z = 0


Call Add_1(x, y, z)


Sheet1.Cells(2, 2) = x


Sheet1.Cells(3, 2) = y


Sheet1.Cells(4, 2) = z


'By Value Method 1


x = 1


y = 2


z = 0


Call Add_1((x), (y), (z))


Sheet1.Cells(2, 6) = x


Sheet1.Cells(3, 6) = y


Sheet1.Cells(4, 6) = z


'By Value Method 2


x = 1


y = 2


z = 0


Call Add_2(x, y, z)


Sheet1.Cells(2, 8) = x


Sheet1.Cells(3, 8) = y


Sheet1.Cells(4, 8) = z


End Sub


Sub Add_1(a, b, c)


c = a + b


End Sub


Sub Add_2(ByVal a, ByVal b, ByVal c)


c = a + b


End Sub



May 26, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here